# Imports the random module import random # Assigns ascii art to variables representing each choice. rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____) ---.__(___) ''' # Welcome message and game prompt user_input = input("Welcome to Rock, Paper, Scissors! What do you chose? Type 0 for rock, 1 for paper, 2 for scissors \n") # Assign the computers choice at random computer_choice = random.randint(0, 2) # Converts users choice into an integer for easy calculation and comparisons user_as_int = int(user_input) # If statement for user choosing invalid option, prints out invalid option message if condition is true. if user_as_int >= 3 or user_as_int < 0: print("You selected an invalid option, you lose") # If block for user choosing rock, runs through 3 conditions, computer choosing rock, computer choosing paper # computer choosing scissors. Then assigning Win/Lose/Tie accordingly if user_as_int == 0 and computer_choice == 0: print(f"You chose \n {rock} \n Computer also chose \n {rock} It\'s a Tie.") if user_as_int == 0 and computer_choice == 1: int(f"You chose \n {rock} \n Computer has chosen \n {paper} You lose.") if user_as_int == 0 and computer_choice == 2: print(f"You chose \n {rock} \n Computer has chosen \n {scissors} YOU WIN!!") # If Block for user choosing scissors, works same as rock. if user_as_int == 1 and computer_choice == 0: print(f"You chose \n {paper} \n Computer has chosen \n {rock} YOU WIN!!") if user_as_int == 1 and computer_choice == 1: print(f"You chose \n {paper} \n Computer also chose \n {paper} It\'s a Tie.") if user_as_int == 1 and computer_choice == 2: print(f"You chose \n {paper} \n Computer has chosen \n {scissors} You lose.") if user_as_int == 2 and computer_choice == 0: print(f"You chose \n {scissors} \n Computer has chosen \n {rock} You lose.") if user_as_int == 2 and computer_choice == 1: print(f"You chose \n {scissors} \n Computer has chosen \n {paper} YOU WIN!!!") if user_as_int == 2 and computer_choice == 2: print(f"You chose \n {scissors} \n Computer has chosen \n {scissors} It\'s a Tie.")
As always here is the replit link if you wish to play:
https://replit.com/@JamesBarlow3/rock-paper-scissors-start-1#main.py
https://replit.com/@JamesBarlow3/rock-paper-scissors-start-1#main.py