On 04/28/2015 09:24 PM, Jacqueline G Solis wrote:
hello,

I keep getting a syntax error. Could you please explain why that happens and 
how to correct it.


def main ():
     print( "Welcome to Gonzo Burger!")
     order= int(input("Enter 1 if you want a hamburger,\
     or 2 if you want a cheeseburger:" ))
     if order == 1 :
                print("order: 1")
     else:
                print("Order: 2")

     drink=int(input("Thank you! Next, enter a 1 if you want a Coke,\
     or a 2 if you want a Sprite:")
     if drink == 1 :

The line before this one has a missing right paren at the end. you close the input() function, but not the int() function. So the next thing would have to be a comma, not a reserved token "if"

               print("Order: 1")
     else:
               print("Order: 2")

     print("Thank you! You ordered:")
     if order == 1:
               print("- Hamburger")
     else:
               print("- Cheeseburger")
     if drink == 1 :
               print("- Coke")
     else:
               print("- Sprite")

main ()




-Jackie
p.s: the error happens in the second if statement.

That's a good hint. Better would be to include the full traceback with the error message, instead of a one-word summary. No matter in this caswe, but it's a good habit to get into.

Incidentally, for syntax errors, it's pretty common for the real problem to be in the line before, or even earlier. I'd assume this error pointed at the 'if'. So you're really only going back one token.




--
DaveA
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to