-4

This program is designed to ask a customer for their order, then display their order at the end. For some reason my code isn't working - and causing a SyntaxError as well. I have displayed the plan of the code below:

print("Welcome to Hungary house.")
addDrink = input("Do you want a drink?\n").lower()
drinkChoice = "None"
dish = ""
order = []

if addDrink == "yes":
    print ("What drink would you prefer?")
    print ("1: Fanta")
    print ("2: Coke")
    print ("3: Pepsi")
    print ("4: Sprite")
    drinkChoice = input("please select a drink from the options above\n")

    if drinkChoice == "1" or drinkChoice == "fanta":
        drinkChoice = "Fanta"
        order.insert(0,drinkChoice)
    if drinkChoice == "2" or drinkChoice == "coke":
        drinkChoice = "Coke"
        order.insert(0,drinkChoice)
    if drinkChoice == "3" or drinkChoice == "pepsi":
        drinkChoice = "Pepsi"
        order.insert(0,drinkChoice)
    if drinkChoice == "4" or drinkChoice == "sprite":
        drinkChoice = "Sprite"
        order.insert(0,drinkChoice)

print ("you have chosen this drink: " + drinkChoice)

foodGroup = input("Do you want Italian, Indian or Chinese food?\n")
if foodGroup == "italian" or foodGroup == "Italian":
    dish = input("Do you want Pasta or Pizza?\n")
    if dish == "pizza":
        dish = input("Do you want Grilled chicken or Seasonal vegetables?\n")
        if dish == "seasonal vegetables":
            order.insert(1,dish) 
        if dish == "grilled chicken":
            order.insert(1,dish)

    if dish == "pasta":
        dish = input("Do you want Vegetarian Toppings or meat toppings?\n")
        if dish == "Vegetarian Toppings":
            order.insert(1,dish)
        if dish == "meat toppings":
            order.insert(1,dish)

if foodGroup == "indian" or foodGroup == "Indian":
    dish = input("Do you want Curry or onion bhaji?\n")
    if dish == "Curry":
        dish = input("Do you want Rice or Naan?\n")
        if dish == "Rice":
            order.insert(1,dish) 
        if dish == "Naan":
            order.insert(1,dish)

    if dish == "onion bhaji":
        dish = input("Do you want Chilli or Peppers?\n")
        if dish == "Chilli":
            order.insert(1,dish)
        if dish == "Peppers":
            order.insert(1,dish)

if foodGroup == "chinese" or foodGroup == "Chinese":
    dish = input("Do you want Chicken Wings or onion Noodles?\n")
    if dish == "Chicken Wings":
        dish = input("Do you want Chips or Red peppers?\n")
        if dish == "Chips":
            order.insert(1,dish) 
        if dish == "Red peppers":
            order.insert(1,dish)

    if dish == "Noodles":
        dish = input("Do you want Meatballs or Chicken?\n")
        if dish == "Meatballs":
            order.insert(1,dish)
        if dish == "Chicken":
            order.insert(1,dish)            

print ("You have ordered",order"enjoy your meal")

This is how the code is supposed to work: User is prompted to choose a drink, then a cuisine, then a dish. After this, the program displays the order the user wanted.

Idos
  • 15,053
  • 14
  • 60
  • 75
Jdowg
  • 33
  • 5

1 Answers1

2

Well, I've run the code and the invalid syntax is simply at the last line:

order = []
>>> print ("You have ordered",order"enjoy your meal")
SyntaxError: invalid syntax

Change it to print ("You have ordered", order ,"enjoy your meal")

>>> print ("You have ordered", order ,"enjoy your meal")
('You have ordered', [], 'enjoy your meal')

Edit: seems like it works:

>>> 
Welcome to Hungary house.
Do you want a drink?
"yes"
What drink would you prefer?
1: Fanta
2: Coke
3: Pepsi
4: Sprite
please select a drink from the options above
"1"
you have chosen this drink: Fanta
Do you want Italian, Indian or Chinese food?
"indian"
Do you want Curry or onion bhaji?
"Curry"
Do you want Rice or Naan?
"Rice"
('You have ordered', ['Fanta', 'Rice'], 'enjoy your meal')

You don't see "Curry" because you don't actually add it to the order, but only the "Rice" side dish...

Idos
  • 15,053
  • 14
  • 60
  • 75
  • Thanks,For some reason its not displaying all of the order on to this list.Why is this? – Jdowg Jan 30 '16 at 18:17
  • You will have to debug your code to see why. I don't know which inputs you are entering. As far as I can see it should be ok if inputs are entered correctly. (my order variable was just order = [] so that's why it's empty) – Idos Jan 30 '16 at 18:19
  • Read here about pdb: http://stackoverflow.com/questions/4929251/can-you-step-through-python-code-to-help-debug-issues It allows you to view your code "step-by-step" each line, and see the variables values change... this is how you check everything is working properly – Idos Jan 30 '16 at 18:21
  • Should i add the last line,(On the answer) – Jdowg Jan 30 '16 at 18:25
  • For some reason my Indian and Chinese are not working properly – Jdowg Jan 30 '16 at 18:32
  • It works for me, make sure you type the items correctly. Write "Curry" and not "curry", write "Rice" and not "rice" (you might want to change it in your program to .lower() like you did at first. – Idos Jan 30 '16 at 18:35
  • Okay,The Indian options don't write to a list properly – Jdowg Jan 30 '16 at 18:37
  • They do, look at my edit... It all works "like the program is". I can imagine you want it to print "Curry", "Rice", "Fanta", but you just add "Rice" and not "Curry". You can add both of them of you add more order.insert() statements. good luck :) – Idos Jan 30 '16 at 18:38