Skip to content
← Back to Community
Invalid Syntax
Profile icon
HunterBerg

how do i fix this? (line 53)
pyrthon

Voters
Profile icon
SAOUD-ABDULAZIZ
Profile icon
HunterBerg
Comments
hotnewtop
Profile icon
EchoCoding

Some suggestions:
Pick more meaningful variable names, as they will help you achieve better readability.
Edit your code for proper indentation.

Regardless, I edited the indentation of your program, which you can find below.

def main(): list = ["hamburger", "steak", "mac and cheese"] #List print("What is your favorite main course out of these?: ", len(list)) print(list) a1 = input("") #variable if a1 == "hamburger": print("That sounds delicious") print("What condoments would you like on your burger?") condement = input("") list.remove("hamburger") print(condement) while True: #condement question print("To clarify, you want", condement, "on your hamburger?") cq =input("") #variable if cq == "yes": print("sounds good!") break else: continue elif a1 == "mac and cheese": while True: print("Sounds delious, what kind of cheese would you like on your macaroni?") mq = input("") print("just to make sure you want", mq, "on your macaroni?") mq2 = input() if mq2 == "yes": print("ok, thanks for clarifying") break elif mq2 == "no": continue elif a1 == "steak": while True: print("Sounds good, how would you like it done") sq = input("") sq2 =print("So you would like your steak done", sq) if sq2 == "yes": print("Sounds good") else: continue main()
Profile icon
hoop4life

@HunterBerg sorry
and what was your code going to do
I am curious...

Profile icon
HunterBerg

@hoop4life creating a meal out of a list of main courses sides and drinks

Profile icon
NightKnight2

You could just remove the else statement. It seemed to work like that

Profile icon
hoop4life

I think

Profile icon
hoop4life

tab the 'continue' 2 times from where it is now

Profile icon
HunterBerg

@hoop4life didnt work

Profile icon
trg5503

Remove the blank line between the "break" and "else"

Profile icon
HunterBerg

@trg5503 didnt work

Profile icon
trg5503

@HunterBerg I was looking at the wrong line, now I see your issue

Python uses whitespace very strictly, unlike many other general languages like JavaScript. Since your "else" statement on line 52 matches the same whitespace as the bit above, it doesn't correctly match it up with the if statement.

You can fix this by removing 2 spaces before the "else"

Profile icon
HunterBerg

@trg5503 is this what you mean
python2

Profile icon
HunterBerg

@trg5503 if it is it doesnt work

Profile icon
valanbechtold

unindent the else: and continue once, it should read on the same lines as your if sq2 == "yes"
@HunterBerg