So I am making the menu for a rock paper scissors game, and it's working other than the quit function in the main menu.
I know that it's because the blank space used for enter is considered a string, but the assignment requires that I use enter to quit from the main menu. Can someone show me the operation I am missing that tells IDLE to take a string as input? or how to possibly convert it from a string to an int?
Here's my code:
def menuMain():
print("--------------------------------------------------------")
print(" Welcome to the wonderful world of Paper Rock Scissors! ")
print("--------------------------------------------------------\n")
print(" 1) One Player Game ( One human playing against the computer.) \n")
print(" 2) Enter for a Two Player Game ( Two humans playing against each other.) \n")
print(" Choose game type or press ENTER to quit game. \n")
print("-----------------------------------------------")
menuChoice = eval(input(" Please enter a choice from the above menu: \n-----------------------------------------------\n"))
if (menuChoice == 1):
print(" You have decided to play a one player game against the computer. \n")
print(" 1) Paper \n")
print(" 2) Rock \n")
print(" 3) Scissors \n")
print(" 4) Quit \n")
subMenuChoice = eval(input( "Please choose from the above weapons menu: \n"))
if( subMenuChoice == 1):
print(" You have chosen Paper. ")
elif(subMenuChoice == 2):
print(" You have chosen Rock. ")
elif(subMenuChoice == 3):
print(" You have chosen Scissors. ")
elif(subMenuChoice == 4):
print(" You have chosen to quit. ")
return 0
else:
print(" Invalid menu choice. ")
elif (menuChoice == 2):
print (" You have decided to play a two player game against another human. ")
print(" 1) Paper \n")
print(" 2) Rock \n")
print(" 3) Scissors \n")
print(" 4) Quit \n")
subMenuChoice = eval(input(" Please choose from the above weapons menu: \n"))
if( subMenuChoice == 1):
print(" You have chosen Paper. ")
elif(subMenuChoice == 2):
print(" You have chosen Rock. ")
elif(subMenuChoice == 3):
print(" You have chosen Scissors. ")
elif(subMenuChoice == 4):
print(" You have chosen to quit. ")
return 0
else:
print(" Invalid menu choice. ")
elif (menuChoice == ""):
print (" Quitting game. Thank you for playing, please play again soon. ")
return 0
else:
print(" Invalid menu choice. ")
menuMain()
Please just help me with this part...I'm not interested in hearing how I can shorten everything up, I'm trying to build this from the ground up first.
Thanks