def main():
pass
menu = [('Pricot Chicken', 8.50), ('Meat Lovers', 13.50), ('Vegetarian', 13.50), ('Double Cheese', 13.50), ('Hawaiian', 13.50), ('Pepperoni', 8.50), ('Beef and Onion', 8.50), ('Ham and Cheese', 8.50), ('Tomato Margherita', 8.50), ('Classic Italian', 8.50), ('BBQ Chicken and Bacon', 8.50), ('Italian Veg', 8.50)]
print ("Wellcome to Ethans Pizza Code")
name1 = (input("What is your order name: "))
def D_or_P(): # error checked to make sure yes or no is entured if not it will repeat till it is.
pass
question_not_answered = True
while (question_not_answered):
d_or_p =input("Will this order Be Delivery? (yes or no): ").lower()
if (d_or_p == 'yes'):
d_or_p = 3
question_not_answered = False
elif (d_or_p == 'no'):
d_or_p = 0
question_not_answered = False
else:
print('Error: Not a yes or no')
if d_or_p in (range (3,4)): # only asks these if d_or_p = yes
PH = input ("what is your phone number?: ") # cant get it to loop if no number is entered so i had to leave it otherwise it would crash
Ad = input ("what is your address: ")
# done
def num_pizzas(): # asks what pizzas you would like to order if any number ordered thats not 1-5 it will repeted till it is
pass
while True:
try:
num_pizzas= int (input('How many pizzas do u want to buy? (limit 5): '))
if num_pizzas in (range (1, 6)):
break
elif num_pizzas not in (range (1, 6)):
pass
except ValueError:
pass
print ("Please enter number betwen 1- 5")
fmt, nfmt = '{0:<30} {1:>9} {2:>9}'.format, '{0:0.2f}'.format #formats menu to use names and prices in reset
print('\n'.join('{0:>3}. {1:<30} {2:>9}'.format(i+1, name, (" $")+nfmt(price)) for i, (name, price) in enumerate(menu))) # splits menu into price and name and prints the menu
print ("What pizzas would you like to order? separated by a space (please type in the numebr for the pizza)")
print (("please note if you order any more pizzas then"),num_pizzas,("they will be removoed from the order and not counted by the order.\n but you can enter less then"),num_pizzas,("if you dont like the choices very much"))
print ("any numbers you enter that are not a pizza will not be counted")
order = ([ i for i in (int(s)-1 for s in input().split() if s.isdigit()) if i in range(len(menu)) ]) #splits numbers entred to be used in order
del order [num_pizzas:] #deletes extra numbers that aren't alowed
# cant limt the amount of pizzas in order so i deleted the rest of them but the customer is told this.
print (("order for"),name1) # prints your name you typed in earlier
print("Your order:")
print(fmt('Item', 'Price', 'Total'))
total = 0.0
for i in order:
name, price = menu[i]
total += price
print(fmt(name, (" $")+nfmt(price), (" $")+nfmt(total))) #prints name price and total so far with the pizzas
print(fmt('delivery', (" $")+nfmt(d_or_p), (" $")+nfmt(total))) # adds delivery charge to total cost
print(fmt('Grand Total','', (" $")+nfmt(total+ d_or_p))) #prints total cost
if d_or_p in (range (3,4)): #only prints if delivery is yes
print (("your address is"),Ad,("your phone number is"),PH,)
elif d_or_p not in (range (3,4)):
print ("")
print ("Thanks for using Ethans python pizza code thank you come agian")
new_order = input("would u like to make another order?") #need to loop to start
i would like to know how to get this code to restart from the beginning if new_order == yes thanks

New Topic/Question
Reply



MultiQuote





|