s, s > p, p > r if is_win(user, computer): return 'you won!' return 'You lost!' def is_win (player, opponent): #return true if player wins #r > s, s > p, p > r if (player == 'r' and opponent == 's') or (player == 's' and opponent == 'p') \ or (player == 'p' and opponent == 'r'): return True print(play())"> s, s > p, p > r if is_win(user, computer): return 'you won!' return 'You lost!' def is_win (player, opponent): #return true if player wins #r > s, s > p, p > r if (player == 'r' and opponent == 's') or (player == 's' and opponent == 'p') \ or (player == 'p' and opponent == 'r'): return True print(play())"> s, s > p, p > r if is_win(user, computer): return 'you won!' return 'You lost!' def is_win (player, opponent): #return true if player wins #r > s, s > p, p > r if (player == 'r' and opponent == 's') or (player == 's' and opponent == 'p') \ or (player == 'p' and opponent == 'r'): return True print(play())">
import random
def play():
user = input("What's your choice? 'r' for rock, 'p' for paper, 's' for sciccors ")
computer = random.choice(['r', 'p', 's'])
if user == computer:
return 'It\\'s a tie'
#r > s, s > p, p > r
if is_win(user, computer):
return 'you won!'
return 'You lost!'
def is_win (player, opponent):
#return true if player wins
#r > s, s > p, p > r
if (player == 'r' and opponent == 's') or (player == 's' and opponent == 'p') \\
or (player == 'p' and opponent == 'r'):
return True
print(play())
LENOVO@SHA-PC MINGW64 ~/OneDrive/Desktop/python (New-Features) $ C:/python/Python311/python.exe "c:/Users/LENOVO/OneDrive/Desktop/python/Python bash/hello.py" What's your choice? 'r' for rock, 'p' for paper, 's' for sciccors p It's a tie
LENOVO@SHA-PC MINGW64 ~/OneDrive/Desktop/python (New-Features) $ C:/python/Python311/python.exe "c:/Users/LENOVO/OneDrive/Desktop/python/Python bash/hello.py" What's your choice? 'r' for rock, 'p' for paper, 's' for sciccors p you won!