So right now I am trying to figure out how to prompt the user to type in yes or no in order to either continue or end the game. I have the prompt but the program will not end only continue, please help.
Here is my code:
[python]
import random
import time
def main():
print("This is a rock, paper, scissor game")
while play_again.upper == 'Y':
return True
return False
play_again = True
def rps():
print("This is a rock, paper, scissor game")
time.sleep(3)
move_list = ['Rock', 'Paper', 'Scissors']
while play_again == True:
for comp in move_list:
user = input('What\'s your hand?: ')
user = user.capitalize()
comp = random.choice(list(move_list))
if comp == 'Rock' and user == 'Paper':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Win!")
elif comp == 'Rock' and user == 'Rock':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("It's a draw")
elif comp == 'Rock' and user == 'Scissor':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Lose!")
elif comp == 'Scissors' and user == 'Paper':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Lose!")
elif comp == 'Scissors' and user == 'Rock':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Lose!")
elif comp == 'Scissors' and user == 'Scissors':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("It's a Draw!")
elif comp == 'Paper' and user == 'Paper':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("It's a Draw!")
elif comp == 'Paper' and user == 'Rock':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Lose!")
elif comp == 'Paper' and user == 'Scissors':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Win!")
else:
print("You messed up the program dummy")
print(comp)
answer = input("Would you like to play again?: ")
rps()
main()
Here is my code:
[python]
import random
import time
def main():
print("This is a rock, paper, scissor game")
while play_again.upper == 'Y':
return True
return False
play_again = True
def rps():
print("This is a rock, paper, scissor game")
time.sleep(3)
move_list = ['Rock', 'Paper', 'Scissors']
while play_again == True:
for comp in move_list:
user = input('What\'s your hand?: ')
user = user.capitalize()
comp = random.choice(list(move_list))
if comp == 'Rock' and user == 'Paper':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Win!")
elif comp == 'Rock' and user == 'Rock':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("It's a draw")
elif comp == 'Rock' and user == 'Scissor':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Lose!")
elif comp == 'Scissors' and user == 'Paper':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Lose!")
elif comp == 'Scissors' and user == 'Rock':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Lose!")
elif comp == 'Scissors' and user == 'Scissors':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("It's a Draw!")
elif comp == 'Paper' and user == 'Paper':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("It's a Draw!")
elif comp == 'Paper' and user == 'Rock':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Lose!")
elif comp == 'Paper' and user == 'Scissors':
print("Computer throws " + comp + " you have thrown " + user + "!")
print("You Win!")
else:
print("You messed up the program dummy")
print(comp)
answer = input("Would you like to play again?: ")
rps()
main()