[Tutor] if then statements

Alan Gauld alan.gauld at btinternet.com
Wed Apr 29 10:08:35 CEST 2015


On 29/04/15 02:24, Jacqueline G Solis wrote:
> hello,
>
> I keep getting a syntax error.

If you get an error always include the full message text in your 
queries. It helps enormously in finding the problem.

> Could you please explain why that happens and how to correct it.

But in this case its obvious...

> 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:")

Count the parentheses in the line above.

> p.s: the error happens in the second if statement.

If you'd sent the error message you wouldn't have to tell us that :-)


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list