DEV Community

Cindy Hernandez
Cindy Hernandez

Posted on

Creating a Rock, Paper, Scissors Game using Python

The goal was to create a rock, paper, scissors game that the user can play against the computer.


Press the RUN button to play!



If we take a look at the main.py file we will be able to see the breakdown of the code. We begin by making the text art images and set them as variables.


Art Images


We can then set the text art image variables in a list, that way we are able to print the image along with the player and computer choice.

In order to receive the number we need to create an input that will be saved as a variable when the player types their choice.

After this section it is important to create an if/else in case the player types an invalid number that is not (0-2).


Second part


Now we can work on creating the computer choice. The computer choice variable will equal a random integer from 0-2.
In order to use random.randint() we must import the random module.


Third part


In order for the game to execute the correct win or lose we need to create if/elif/else statements.


Text art sources: https://gist.github.com/wynand1004/b5c521ea8392e9c6bfe101b025c39abe#file-rps_ascii_art-py

Top comments (0)