Day 003 of the 100 Days of Python challenge is a command-line Rock Paper Scissors game. The player selects rock, paper, or scissors, and Python randomly chooses an opponent move.
Project Overview
The game maps the three choices to numbers:
0for rock1for paper2for scissors
A list stores the ASCII illustrations for those choices. After converting valid input to an integer, the program displays both selections and compares them.
computer_choice = random.randint(0, 2)
The random module supplies the computer’s move. The game then checks the three winning combinations, handles a draw, and reports a loss for every remaining valid combination.
Input Validation
The program checks that the input contains digits and that the resulting number is one of 0, 1, or 2. Invalid input produces a loss message instead of attempting to index the image list with an unsupported value.
This is a small but important example of validating data before using it. Without the range check, an invalid number could raise an IndexError.
What This Project Teaches
Day 003 provides practice with importing modules, generating random values, storing related data in lists, converting input, and expressing game rules with conditionals. The ASCII art also shows how text can improve a terminal program’s feedback.
Running the Project
cd 100daysofpython/day003
python main.py
View the Day 003 source code on GitHub.
