Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- computer_win = 0
- user_win = 0
- options = ["rock", "paper", "scissors"]
- while True:
- user_input = input("Choose Rock/Paper/Scissors or [Q] to quit: ").lower()
- if user_input == "q":
- break
- if user_input not in options:
- print('Please enter a valid option.')
- continue
- random_numer = random.randint(0, 2)
- #rock - 0, paper - 1, scissors - 2.
- computer_pick = options[random_numer]
- if (
- user_input == 'rock' and computer_pick == 'scissors'
- or user_input == 'paper' and computer_pick == 'rock'
- or user_input == 'scissors' and computer_pick == 'paper'
- ):
- print('Congratulations, you WON! 😁')
- user_win += 1
- else:
- print('You LOST! 😢')
- computer_win += 1
- print('You won', str(user_win) + ' times. 😁')
- print('The computer won', str(computer_win) + ' times. 😢')
- print('Bye Bye, until the next time. 😎')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement