Advertisement
gruntfutuk

Ok_Can2925

Nov 21st, 2023
898
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. #How to play rock paper scissors!
  2. import random
  3.  
  4. print("Welcome to Rock Paper Scissors!!!")
  5. user_wins = 0
  6. computer_wins = 0
  7. options = ["rock", "paper", "scissors"]
  8.  
  9. #0,1,2
  10. def game_step():
  11.  
  12.     global user_wins
  13.     global computer_wins
  14.  
  15. while True:
  16.     user_input = input("Type Rock/Paper/Scissors or Q to quit: ").lower()
  17.     if user_input == "q":
  18.         break
  19.     if user_input not in options:
  20.         continue
  21.     random_number = random.randint(0, 2)
  22.  
  23.     #rock: 0, paper: 1, scissors: 2
  24.     computer_pick = options[random_number]
  25.     print("Computer picked", computer_pick + ".")
  26.  
  27.     if user_input == "rock" and computer_pick == "scissors":
  28.         print("You won!")
  29.         user_wins += 1
  30.     elif user_input == "paper" and computer_pick == "rock":
  31.         print("You won!")
  32.         user_wins += 1
  33.     elif user_input == "scissors" and computer_pick == "paper":
  34.         print("You won")
  35.         user_wins += 1
  36.     else:
  37.         print("You lost!")
  38.         computer_wins += 1
  39.  
  40. print("You won", user_wins, "times.")
  41. print("The computer won", computer_wins, "times.")
  42. print("Goodbye!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement