Can someone tell me how to fix the 1st inner loop? I want the user to be able to quit the program inputting quit but its not working

Joined
Mar 16, 2025
Messages
1
Reaction score
0
# chips = 1.00
# chocolate = 1.50
# soda = 1.20
# ch=("chips")
# cho=("chocolate")
# sod=("soda")
# while True:
# print("""Welcome to the Vending Machine!
# Items Available:
# 1. Chips - £1.00
# 2. Chocolate - £1.50
# 3. Soda - £1.20""")
#
# try:
# choice = int(input("Please select between 1-3: "))
#
# if choice in [1,2,3]:
# if choice==1:
# print(f"You selected {ch} which is £{chips}")
# price=chips
# elif choice ==2:
# print(f"you selected {cho} which is £{chocolate}")
# price=chocolate
# elif choice ==3:
# print(f"you selected {sod} which is £{soda}")
# price=soda
#
# else:
# print("Invalid please select between 1 and 3")
# continue
# except ValueError:
# print('Invalid Input, You must select a NUMBER between 1-3')
# continue
#
# s=True
#
# money = input('Please insert your money (CASH GBP Only) under £10: ')
# while True:
#
# if money.lower() == "quit":
# print("Transaction cancelled. Get your money up")
# s=False
# break
# try:
# money = float(money)
# if money > 10 or money<1:
# print("You cannot insert money greater or lower than £10 or enter " ,0.0)
# continue
#
# else:
# break
# except ValueError:
# print("Invalid input. Please enter a number. or enter [exit]")
# continue
#
#
#
#
#
#
#
#
# change= money-price
#
#
#
#
#
# if money < price:
# while True:
# print("You do not have enough!")
# change2 = input('Please insert more change or input "quit" to exit: ')
#
# # Check if the user wants to quit
# if change2.lower() == 'quit':
# print("Transaction cancelled. Get your money up")
# print("-" * 100)
# break
#
#
# try:
# change2 = float(change2)
# money+=change2
#
# if money >= price:
# if money == price:
# print("You have paid the exact amount. No change due.")
# print("-" * 100)
# break
#
# else:
# change2 = money - price
# print("You have paid the price of the product")
# print(f"Here's your change: £{round(change2, 2)}")
# print("-" * 100)
# break
#
# else:
# print(f"You still need £{price - money:.2f} more.")
# except ValueError:
# print("Invalid input. Please enter a valid amount or type 'quit' to exit.")
#
#
# elif money == price:
# print("You have enough to purchase this item.")
# print("Goodbye :)")
# print("-" * 100)
#
#
#
# elif money > price:
# print(f"Here is your change: ", round(change,3))
# print("Goodbye :)")
# print("-"*100)
#
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,300
Messages
2,571,537
Members
48,327
Latest member
GWEDalene9
Top