samedi 30 janvier 2016

Code is not displaying all of the order to the list and causes SyntaxError

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.

Aucun commentaire:

Enregistrer un commentaire