Snippets Collections
import random

rock = '''
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
'''

paper = '''
    _______
---'   ____)____
          ______)
          _______)
         _______)
---.__________)
'''

scissors = '''
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
'''


user_choices = ["0","1","2"]
image_list = [rock, paper, scissors]
choice = input("What do you choose? Type 0 for Rock, 1 for Paper, or 2 for Scissors.\n")

if choice not in user_choices:
    print("Invalid input. Game Over.")
else:
    player1 = int(choice)

    print(image_list[player1])

    computer = random.randint(0,2)

    print(f"\nComputer chose:\n\n{image_list[computer]}")

    if player1 == computer:
        message = "It's a draw"
    elif (player1 == 0 and computer == 2) or (player1 == 2 and computer == 1) or (player1 == 1 and computer == 0):
        message = "You win!"
    else:
        message = "You lose!"

    print(f"\n{message}")
        

    
star

Wed Aug 31 2022 08:24:09 GMT+0000 (Coordinated Universal Time)

#python #rock #paper #scissors

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension