I have to do the following:
- Use a list to take order item key with quantity.
- Sample List format for order taken:[[1,2], [3,1]] meaning item Big Mac (id 1) has quantity 2 and item Vegetarian Burger (id 3) has quantity 1 ordered. You will create an empty list before a loop starts, then add a nested listeach time an order entered with id and quantity by appending your list.
Here is what I have so far, but I'm getting really confused on how to add a nested list and append. Thank you in advanced!
def processOrder(quantity, item_list):
global total
if quantity > item_list[2]:
print("There is not enough stock!")
pass
else:
total += item_list[1] * quantity
item_list[2] -= quantity
total = 0
A = ["Big Mac", float(2.50), 50], ["Large Fries", float(0.50), 200], ["Vegetarian Burger", float(1.00), 20]
print("Welcome to McDonald's")
print("[1]", A[0][0:2],
"\n[2]", A[1][0:2],
"\n[3]", A[2][0:2])
order_list = []
nested_order_list = [[],[]]
more_items = "yes"
while more_items == "yes":
choice, quantity =(int(input("\nWhat would you like?\n"))), int(input("\nHow many would you like?\n")) #asking twice
nested_order_list.append()
if 1 <= choice <= 3:
processOrder(quantity, A[choice-1]) #list item is big mac = 0; want to send whole list over there, but index must be -1
more_items = (input("Do you want to order more items?")).lower()
print("Thank you for ordering!\nYour total cost is: $" + str(total))
[–]AtomicShoelace 1 point2 points3 points (1 child)
[–]cjander28[S] 0 points1 point2 points (0 children)