Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Help w/ Programming assignment!
Post Body

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

Author
Account Strength
90%
Account Age
5 years
Verified Email
Yes
Verified Flair
No
Total Karma
774
Link Karma
161
Comment Karma
540
Profile updated: 1 day ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago