samedi 30 janvier 2016

My code isnt writing to a list.The error is that the details are not displayed properly at the end

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. The problem is when the customer enters in their details,the details are not displayed properly at the end. What the code is supposed to do is displayed at the bottom.

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 Indian or Chinese food?\n").lower()
if foodGroup == "indian" or foodGroup == "Indian":
    dish = input("Do you want Curry or onion bhaji?\n").lower()
    if dish == "Curry":
        order.insert(1,dish)
        dish = input("Do you want Rice or Naan?\n").lower()
        if dish == "Rice":
            order.insert(2,dish) 
        if dish == "Naan":
            order.insert(2,dish)

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

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

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

print ("You have ordered the following",order,"You are order number 294")

What the code is supposed to do is displayed below.

Welcome to Hungary house.
Do you want a drink?
If no, Move on to the next question
If yes, ask what drink the customer wants.
(Coke, Fanta, lemonade are the options)
If coke is chosen, set coke as drink
If Fanta is chosen, set Fanta as drink
If Lemonade is chosen, set Lemonade as drink

Do you want Indian or Chinese food?

If Indian food is entered ask the following questions
Do you want Curry or onion bhaji?
If curry is selected ask the following questions.
What toppings you want on top of your Curry?
Rice 
Or 
Naan
If user enters rice, add rice on to the curry.
If user enters Naan, add naan on to the curry.
If user enters onion ask the following questions.
What toppings do you want on top of your onion bhaji?
Chilli source
Or 
Naan 
If user enters Chilli source, add chilli source on to the onion bhaji.
If user enters Naan, add Naan on to the onion bhaji.

.

If Chinese food is entered ask the following questions.
Do you want Chicken wings or Noodles?
If Chicken wings is chosen ask,
Do you want with your Chicken wings?
Green Peppers
Or
Red Peppers
If Green pepper is chosen add that to the Green Peppers to the Chicken wings
If Red Peppers are chosen add that to the Chicken wings.
If the user enters Noodles ask the following questions.
Choose the toppings you want with Noodles.
Meatballs 
Or
Chicken 
If user enters Meatballs, add Meatballs to the Noodles.
If user enters Chicken, add Chicken to the Noodles. 

After this, display the order the user wanted, tell the customer that their order will come within the nextemphasized text 10-50 minutes. If they wish to cancel tell them to contact this number ‘077 3475 XXXXXX’.

Aucun commentaire:

Enregistrer un commentaire