Reputation: 86
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.
Upvotes: 0
Views: 98
Reputation: 28292
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")
Upvotes: 0
Reputation: 13372
input()
has an unnecessary paranthesis in the beginning.if
statement is wrongly indented more.elif
doesn't have a :
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")
Upvotes: 0