How can I add an exit option... I want to be able to select #5 and it exit loop and print me out a total of my selected donuts!
print("Welcome, to Dino's International Doughnut Shoppe!") name = input("Please enter your name to begin!:") fileout= open("Dinos.txt", "w") fileout.write(name + "\n") x=input while x!=5: print("Please select a doughnut from the following menu:") print("1. Chocolate-dipped Maple Puff ($3.50 each)") print("2. Strawberry Twizzler ($2.25 each)") print("3. Vanilla Chai Strudel ($4.05 each)") print("4. Honey-drizzled Lemon Dutchie ($1.99)") print("5. No more doughnuts.") x = int(input()) if x > 5: print("I'm sorry, that's not a valid selection. Please enter a selection from 1-4.") x= int(input()) if x == 1: print("How many Chocolate-dipped Maple Puffs would you like to purchase?") fileout= open("Dinos.txt","a") fileout.write("Chocolate- dipped Maple Puffs\n") fileout.write(str("3.50\n")) fileout.close() if x == 2: print("How many Strawberry Twizzlers would you like to purchase?") fileout=open("Dinos.txt","a") fileout.write("Strawberry Twizzlers\n") fileout.write(str("2.25\n")) fileout.close() if x == 3: print("How many Vanilla Chai Strudels would you like to purchase?") fileout=open("Dinos.txt","a") fileout.write("Vanilla Chai Strudels\n") fileout.write(str("4.05\n")) fileout.close() if x == 4: print("How many Honey-drizzled Lemon Dutchies would you like to purchase?") fileout=open("Dinos.txt","a") fileout.write("Honey-drizzled Lemon Dutchies\n") fileout.write(str("1.99\n")) fileout.close() y=int(input()) fileout=open("Dinos.txt","a") fileout.write(str(y)) fileout.close() filein= open("Dinos.txt","r") for i in range(0-4): for line in "Dinos.txt": data = line.split("\n") name= data [0] itemCode= float(data[1]) itemPrice = float(data[2]) itemQty= float(data[3]) if(y > 1): filein= open("Dinos.txt","r") for i in range(0-4): for line in "Dinos.txt": data = line.split("\n") name= data [0] itemCode= float(data[1]) itemPrice = float(data[2]) itemQty= float(data[3]) Total= y* itemPrice if y ==1: filein= open("Dinos.txt","r") for i in range(0-4): for line in "Dinos.txt": data = line.split("\n") name= data [0] itemCode= float(data[1]) itemPrice = float(data[2]) itemQty= float(data[3]) Total=(itemPrice) print(name + ", here is your recipt:") print("-------------------------------") itemCode= filein.readline().strip() itemPrice=(filein.readline().strip()) itemQty= (filein.readline().strip()) filein= open("Dinos.txt","r") for i in range(0-4): for line in "Dinos.txt": data = line.split("\n") name= data [0] itemCode= float(data[1]) itemPrice = float(data[2]) itemQty= float(data[3]) print(y),print(itemPrice) fileout.close() print("-------------------------------") if(int(y > 1)): filein= open("Dinos.txt","r") for i in range(0-4): for line in "Dinos.txt": data = line.split("\n") name= data [0] itemCode= float(data[1]) itemPrice = float(data[2]) itemQty= float(data[3]) total=float(y)*float(itemQty) fileout.close() print("Cost: $",total) print("Thank you, have a nice day\n")