price = {"Lemonade": 1.50, "Coke": 2.00, "Fanta": 1.00, "Water": 0.50}
shopping_basket = {}
print("Welcome to the online drink store!\nThese are the drinks we offer.\n1. Lemonade: £1.50\n2. Coke: £2.00\n3. Fanta £1.00\n4. Water: £0.50\n")
buy_another_flag = 1
total_cost, total = 0, 0
while buy_another_flag != 0:
option = int(input("Which drink would you like to purchase?: "))
if option == 1:
qnty = int(input("Enter the quantity: "))
total = qnty * 1.50
print("The price is: " + str(total))
elif option == 2:
qnty = int(input("Enter the quantity: "))
total = qnty * 2.00
print("The price is: " + str(total))
elif option == 3:
qnty = int(input("Enter the quantity: "))
total = qnty * 1.00
print("The price is: " + str(total))
elif option == 4:
qnty = int(input("Enter the quantity: "))
total = qnty * 0.50
print("The price is: " + str(total))
total_cost += total
buy_another_flag = int(input("Would you like another item? enter Yes (1) or No (0):"))
print("The total price of your basket is: ", total_cost)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter