frederick99

Rock-paper-scissors

Oct 28th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. DICT = {'scissors': 0, 'rock': 1, 'paper':2}
  2.  
  3. def play(a,b):
  4.   return ['Tie', 'Player 1 wins', 'Player 2 wins'][(DICT[a] - DICT[b]) % 3]
  5.  
  6. def get_input(player_name):
  7.   return input(f'{player_name} (Enter rock, paper or scissors): ').strip().lower()
  8.  
  9. result = 'Tie'
  10.  
  11. while result == 'Tie':
  12.   player1 = get_input('Player 1')
  13.   player2 = get_input('Player 2')
  14.  
  15.   result = play(player1, player2)
  16.  
  17.   print(result)
Add Comment
Please, Sign In to add comment