We can make a basic version of Rock, Paper, Scissors game using Python's random module and conditional statements. Here's the code:
main.py487 chars20 lines
In this code, the play()
function takes user's choice as input and uses the random
module to generate a random choice for the computer. Then it checks the user's choice against the computer's choice to determine the winner using the is_win()
function.
The is_win()
function implements the basic rules of Rock, Paper, Scissors game - rock beats scissors, scissors beats paper and paper beats rock.
To play the game, simply run the play()
function.
gistlibby LogSnag