Live demo
Click the button to roll two virtual dice — exactly like the Python game.
-
-
Click to roll
Quick start
No dependencies, no virtual environment, no build step. Works with any Python 3.
# Clone the repo git clone git@github.com:Chenboda01/Python-Dice-Rolling-Game.git cd Python-Dice-Rolling-Game # Run the game python3 dice-game.py
Usage
The game prompts you on each turn:
Roll the dice? (y/n): y (42, 17) Roll the dice? (y/n): y (5, 33) Roll the dice? (y/n): n Thanks for playing!
- Enter
y— roll both dice - Enter
n— exit the game - Any other input — shows
Invalid choice!and re-prompts
Dice behavior
- Each die rolls a random integer from 1 to 50 (intentionally non-standard)
- Two dice per roll, displayed as
(die1, die2) - Loop continues until the player enters
n
Source code
The entire game is a single 13-line Python script — no external packages, no config files.
import random while True: choice = input('Roll the dice? (y/n): ').lower() if choice == 'y': die1 = random.randint(1, 50) die2 = random.randint(1, 50) print(f'({die1}, {die2})') elif choice == 'n': print('Thanks for playing!') break else: print('Invalid choice!')