0

Before you ask, I did look at other answers and questions they all seem to be the same and yes I did add it but still nothing. Okay, so I have a program with a menu and at the menu choice it keeps coming up with syntax error at the ":" colon, help please I have tried everything. Here's the code :

def main(): print("Hello and Welcome to the 'Say When' program") print("1:Class\n2:Priamry\n3:Secondary\n4:FirstGag\n5:SecondGag") menu = (input("What would you like to search?: ") if menu == '1': print("You chose Class") list = ['Assault', 'Engineer', 'Support', 'Recon'] from random import choice print(choice(list)) elif menu == '2' print("nice") 

Error = Syntax error then it highlights the ":" in red.

3
  • 1
    Your indentation looks wrong, why is the if indented more than the previous line? Commented Nov 10, 2013 at 16:42
  • You have an extra ( before input. Also, are you using Pythong 2.x or 3.x? Commented Nov 10, 2013 at 16:43
  • There are many things wrong here. Commented Sep 15, 2023 at 4:48

2 Answers 2

0

You're missing a closing parentheses on your input function, which you don't need at all.

menu = input("What would you like to search?: ") 

Full fixed code:

def main(): print("Hello and Welcome to the 'Say When' program") print("1:Class\n2:Priamry\n3:Secondary\n4:FirstGag\n5:SecondGag") menu = input("What would you like to search?: ") if menu == '1': print("You chose Class") list = ['Assault', 'Engineer', 'Support', 'Recon'] from random import choice print(choice(list)) elif menu == '2': print("nice") 
Sign up to request clarification or add additional context in comments.

Comments

0
  1. The input() has an unnecessary paranthesis in the beginning.
  2. The if statement is wrongly indented more.
  3. The elif doesn't have a :
  4. Imports must be made at the beginning.

Correct code

from random import choice def main(): print("Hello and Welcome to the 'Say When' program") print("1:Class\n2:Priamry\n3:Secondary\n4:FirstGag\n5:SecondGag") menu = input("What would you like to search?: ") if menu == '1': print("You chose Class") list = ['Assault', 'Engineer', 'Support', 'Recon'] print(choice(list)) elif menu == '2': print("nice") 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.