import random
import time
# start = input('Do you want to play a game of rock, paper, scissors? (Y/Yes or N/No) \n').lower()
# if start == 'y' or 'yes':
def play():
user = input("Would you like to play 'R/Rock', 'P/Paper', or 'S/Scissors'? \n").lower()
if user == 'p':
user = 'paper'
elif user == 'r':
user = 'rock'
elif user == 's':
user = 'scissors'
print(f'You played {user}!')
computer = random.choice(['rock', 'paper', 'scissors'])
print(f'The computer played {computer}!')
time.sleep(0.5)
if user == computer:
return 'Tie game!'
if win_condition(user, computer):
return 'You win!'
return 'You lost :('
def win_condition(player, bot):
if (player == 'r' or 'rock' and bot == 'scissors') or (player == 's' or 'scissors' and bot == 'paper') or \
(player == 'p' or 'paper' and bot == 'rock'):
return True
# elif start == 'n' or 'no':
# quit()
print(play())
I have a couple of questions. First off, sometimes I keep on getting 'You win!' as my result even when I supposedly lose and I am not sure why. Second, how can I make it so that the entire program runs my function if I type 'y' or 'yes' and exits if I say 'n' or 'no' in the beginning (comments in lines 5 and 37). I tried running it where the comments are with an if and elif at the end, but it did not work. A brief explanation would also be very helpful! I am still very new to Python and am still trying to learn/strengthen the basics so I apologize if it's something very obvious and I miss it. If possible, please keep it in more basic/generalized syntax as I do not know the ones past a beginner level. Thank you in advance!