-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanual_rps.py
More file actions
32 lines (25 loc) · 984 Bytes
/
manual_rps.py
File metadata and controls
32 lines (25 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import random
def get_computer_choice():
computer_guess = ['Rock', 'Paper', 'Scissors']
return random.choice(computer_guess)
def get_user_choice():
user_guess = input('Please enter a guess; either Rock, Paper or Scissors: ')
return user_guess.capitalize()
def get_winner(computer, player):
print(f'Computer chose {computer}')
if player == 'Rock' and computer == 'Scissors' or player == 'Paper' and computer == 'Rock' or player == 'Scisors' and computer == 'Paper':
return 'Congratulations! You beat the computer!'
elif player == computer:
return 'Looks like its a draw.'
else:
return 'The computer has won. Better luck next time.'
def play():
player = get_user_choice()
computer = get_computer_choice()
print(get_winner(computer, player))
play_again = input('Would you like to play again? yes or no: ').lower()
if play_again != 'yes':
print('Bye for now!')
else:
play()
play()