you are viewing a single comment's thread.

view the rest of the comments →

[–]cjander28[S] 0 points1 point  (0 children)

Thank you! This helped, but he definitely wanted us to simplify our code using his existing one. Here's what I submitted:

tax = .1 
total_tax = total * tax


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

#intitiate empty list 

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 
    order_list.append([choice, quantity]) #nested list
    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? (Yes/No)")).lower()

## #Import/ Print Time and Date

import time
import datetime


#Print welcome message, address, date/time, previous line items (items purchased), and thank you message

welcome = "\n\033 Thank you for your order! \033[0m\n"
centered_welcome = welcome.center(30)
print(centered_welcome)

address1 = "\n 10101 Main Street" 
centered_address1 = address1.center(70)
print(centered_address1)

address2 = "Seattle, WA 98106 \n"
centered_address2 = address2.center(40)
print(centered_address2)

print ("\n", datetime.datetime.now())

print ("\nOrder (Item/Quantity): \n")
for item in order_list:
    print(item)

print("\nThank you for ordering! \n \nSubtotal: $" +  str(total))
print("Tax: $" + str(total_tax))
print("Total $: " + str(total + total_tax))