Sie sind auf Seite 1von 2

##program

# Depending on the customer's selection, add a value


# into a customer sub total. To keep it simple, assume
# that they'll enter 1, 2, 3, 4 or 0. If they enter
# 1, 2, 3, or 4, add that same number into their sub total
# (e.g. if choice is 1, subtotal += 1, if choice is 2,
# subtotal += 2 etc.). If they enter 0, that will indicate
# they are done and the inner loop should break.

#Add a grand total for the store into the


# code from 2a. Add each customer's sub-total into the
# grand total once they are done adding to their order.
# Also print each customer's sub total once they are
# done ordering, and print the grand total of all sales
# at the very end.
coffee = [["Espresso", 5.75],
["Cappuccino", 6.25],
["Latte", 5.50],
["Regular Coffee", 5.25],
["Decaffe", 4.60]]

def cof_cho(cs):
print("Your", coffee[cs][0], "is being prepared.")
print("Please pay", "${:.2f}".format(coffee[cs][1]), "n")

cof_sel = [ ]

def sho_cho(cs):
# I would like for every cs coming from line 31 to append cof_sel
# and print the list accordingly, each cs chosen should link
# to the sh_name whereas all the cs chosen by sh_name is able to be
# added for a sum total using coffee.index[1]
# I beleive coffee.index[1] is float so I think it needs to be changed
# to integer for addition then printed
for name in sh_name:
sh_name = input("Hello, please enter your name: ___")
while cs != 0:
cs = int(input("Choose your numbered coffee selection or 0 to Quit: "))
if cs != 0:
cof_sel.append(cs)
print("Hello", sh_name)
print("Your coffee selections are: ", coffee[cs][0])

return sho_cho(cs)

repeat = True;
while repeat:
y_n_in = input("Would you like to start a coffee order? n y or n: ")
print()
if y_n_in.lower() == "y":
while True:
for prd in coffee:
print("{}. ".format(coffee.index(prd) + 1), end='')
print("{:20}${:.2f}".format(prd[0], prd[1]))
cs = int(input("Choose your numbered coffee selection or 0 to Quit: "))
while cs != 0:
if cs != 0:
cs -= 1
sho_cho(cs)
break
else:
break
print("Enter a selection of 1 -", len(coffee), "in menu or 0 to quit")
if cs == 0:
print("Thank You, Come Again.n")
elif y_n_in.lower() == "n":
print("Thank you. Goodbye! n")
break
else:
print("Enter y or n, please!")

Das könnte Ihnen auch gefallen