A command-line Python application that simulates rolling one or more dice, tracks your session roll count, and handles invalid inputs gracefully.
- Roll any number of dice in a single turn
- All dice show values between 1 and 6
- Tracks total rolls across the session
- Input validation — handles letters, negative numbers, and zero
- Clean, modular code with unit tests
===================================
Welcome to the Dice Rolling Game!
===================================
How many dice do you want to roll? 3
Dice 1: 4
Dice 2: 1
Dice 3: 6
Total rolls this session: 1
Roll again? (y/n): y
How many dice do you want to roll? abc
Invalid input. Please enter a whole number.
How many dice do you want to roll? 2
Dice 1: 3
Dice 2: 5
Total rolls this session: 2
Roll again? (y/n): n
Thanks for playing! Goodbye 🎲
- Python 3.10 or higher
git clone https://github.com/sanamuqqadus393-arch/Dice-Rolling-Game.git
cd Dice-Rolling-Gamepython dice_rolling_game.pypip install pytest
pytest test_dice_rolling_game.py -vDice-Rolling-Game/
├── dice_rolling_game.py # Main game logic
├── test_dice_rolling_game.py # Unit tests
├── requirements.txt # Dependencies
├── .gitignore
└── README.md
- Python 3.10+
random(standard library)pytest(testing)
- Structuring code into reusable functions
- Input validation with
try/except - Writing unit tests with
pytestandunittest.mock - Python docstrings and type hints
MIT License — see LICENSE for details.