Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #How to play rock paper scissors!
- import random
- print("Welcome to Rock Paper Scissors!!!")
- user_wins = 0
- computer_wins = 0
- options = ["rock", "paper", "scissors"]
- #0,1,2
- def game_step():
- global user_wins
- global computer_wins
- while True:
- user_input = input("Type Rock/Paper/Scissors or Q to quit: ").lower()
- if user_input == "q":
- break
- if user_input not in options:
- continue
- random_number = random.randint(0, 2)
- #rock: 0, paper: 1, scissors: 2
- computer_pick = options[random_number]
- print("Computer picked", computer_pick + ".")
- if user_input == "rock" and computer_pick == "scissors":
- print("You won!")
- user_wins += 1
- elif user_input == "paper" and computer_pick == "rock":
- print("You won!")
- user_wins += 1
- elif user_input == "scissors" and computer_pick == "paper":
- print("You won")
- user_wins += 1
- else:
- print("You lost!")
- computer_wins += 1
- print("You won", user_wins, "times.")
- print("The computer won", computer_wins, "times.")
- print("Goodbye!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement