Uno2K

Projeto Pessoal - Rock/Paper/Scissors

Sep 17th, 2021
563
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2.  
  3. computer_win = 0
  4. user_win = 0
  5. options = ["rock", "paper", "scissors"]
  6.  
  7. while True:
  8.     user_input = input("Choose Rock/Paper/Scissors or [Q] to quit: ").lower()
  9.  
  10.     if user_input == "q":
  11.         break
  12.  
  13.     if user_input not in options:
  14.         print('Please enter a valid option.')
  15.         continue
  16.  
  17.     random_numer = random.randint(0, 2)
  18.     #rock - 0, paper - 1, scissors - 2.
  19.     computer_pick = options[random_numer]
  20.  
  21.     if (
  22.         user_input == 'rock' and computer_pick == 'scissors'
  23.         or user_input == 'paper' and computer_pick == 'rock'
  24.         or user_input == 'scissors' and computer_pick == 'paper'
  25.     ):
  26.         print('Congratulations, you WON! ๐Ÿ˜')
  27.         user_win += 1
  28.     else:
  29.         print('You LOST! ๐Ÿ˜ข')
  30.         computer_win += 1
  31.  
  32. print('You won', str(user_win) + ' times. ๐Ÿ˜')
  33. print('The computer won', str(computer_win) + ' times. ๐Ÿ˜ข')
  34. print('Bye Bye, until the next time. ๐Ÿ˜Ž')
RAW Paste Data