So I wrote this program this evening...it was working just fine and when I started trying to tweak the display I started getting syntax errors on my global elif's. Here's my code, somebody please tell me what is going on.
# Rock Paper Scissors, Project 2, Tadd O'Bannion
import random
def main():
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) Two Player Game ( Two humans playing against each other.) \n")
print(" Choose game type or press ENTER to quit game. \n")
print("--------------------------------------------")
menuChoice = input(" Please enter a choice from the above menu: \n--------------------------------------------\n")
if(menuChoice == "1"):
print("*****************************************************************")
print(" You have decided to play a one player game against the computer. \n")
print("*****************************************************************")
print(" 1) Paper \n")
print(" 2) Rock \n")
print(" 3) Scissors \n")
print(" 4) Quit \n")
while(menuChoice != 4):
subMenuChoice = eval(input( "Please choose from the above weapons menu: \n\n"))
if( subMenuChoice == 1):
print(" You have chosen Paper.\n ")
elif(subMenuChoice == 2):
print(" You have chosen Rock.\n ")
elif(subMenuChoice == 3):
print(" You have chosen Scissors.\n ")
elif(subMenuChoice == 4):
print(" You have chosen to quit.\n ")
return 0
else:
print(" Invalid menu choice...seriously...the menu says 1,2,3 or 4...pay attention! \n ")
computerChoice = random.choice([1, 2, 3])
if( computerChoice == 1):
print(" The computer has chosen Paper.\n ")
elif( computerChoice == 2):
print(" The computer has chosen Rock.\n ")
elif( computerChoice == 3):
print(" The computer has chosen Scissors.\n ")
if subMenuChoice == computerChoice:
print(" Tie! ")
elif (subMenuChoice == 1) and (computerChoice == 2):
print(" Paper covers Rock!! Human player wins!!\n ")
elif (subMenuChoice == 2) and (computerChoice == 3):
print(" Rock smashes Scissors!! Human player wins!!\n ")
elif (subMenuChoice == 3) and (computerChoice == 1):
print(" Scissors cuts Paper!! Human player wins!!\n ")
elif (subMenuChoice == 2) and (computerChoice == 1):
print(" Paper covers Rock!! Computer wins!!\n ")
elif (subMenuChoice == 3) and (computerChoice == 2):
print(" Rock smashes Scissors!! Computer wins!!\n ")
elif (subMenuChoice == 1) and (computerChoice == 3):
print(" Scissors cuts Paper!! Computer wins!!\n ")
elif(menuChoice == "2"):
print("*****************************************************************")
print (" You have decided to play a two player game against another human.\n ")
print("*****************************************************************")
print(" 1) Paper \n")
print(" 2) Rock \n")
print(" 3) Scissors \n")
print(" 4) Quit \n")
while (menuChoice != 4):
player1 = eval(input(" Player 1, please choose from the above weapons menu: \n\n"))
if( player1 == 1):
print(" You have chosen Paper.\n ")
elif(player1 == 2):
print(" You have chosen Rock.\n ")
elif(player1 == 3):
print(" You have chosen Scissors.\n ")
elif(player1 == 4):
print(" You have chosen to quit.\n ")
return 0
else:
print(" Invalid menu choice...seriously...the menu says 1,2,3 or 4...pay attention! ")
player2 = eval(input(" Player 2, please choose from the above weapons menu: \n\n"))
if( player2 == 1):
print(" You have chosen Paper.\n ")
elif(player2 == 2):
print(" You have chosen Rock.\n ")
elif(player2 == 3):
print(" You have chosen Scissors.\n ")
elif(player2 == 4):
print(" You have chosen to quit.\n ")
return 0
else:
print(" Invalid menu choice...seriously...the menu says 1,2,3 or 4...pay attention!\n ")
if player1 == player2:
print(" Tie! ")
elif (player1 == 1) and (player2 == 2):
print(" Paper covers Rock!! Player 1 wins!!!\n ")
elif (player1 == 2) and (player2 == 3):
print(" Rock smashes Scissors!! Player 1 wins!!\n ")
elif (player1 == 3) and (player2 == 1):
print(" Scissors cuts Paper!! Player 1 wins!!\n ")
elif (player1 == 2) and (player2 == 1):
print(" Paper covers Rock!! Player 2 wins!!\n ")
elif (player1 == 3) and (player2 == 2):
print(" Rock smashes Scissors!! Player 2 wins!!\n ")
elif (player1 == 1) and (player2 == 3):
print(" Scissors cuts Paper!! Player 2 wins!!\n ")
elif(menuChoice == ""):
print (" Quitting game. Thank you for playing, please play again soon.\n ")
return 0
else:
print(" Invalid menu choice...seriously...the menu says 1,2 or ENTER...pay attention! \n ")
main()
Please don't tell me how to shorten it, I want this to be a very understandable (from a very new beginner perspective) program so I want to keep it simple.
Thanks in advance.