Skip to the content.

1.4 Error Correction • 2 min read

Description

I corrected the error in the code

menu = {
    "burger": 3.99,
    "fries": 1.99,
    "drink": 0.99
}

total = 0

# Show the user the menu and prompt them to select an item
print("Menu")
for k, v in menu.items():
    print(k + "  $" + str(v))

# Prompt the user multiple times until they want to stop
while True:
    item = input("Please select an item from the menu (or type 'done' to finish): ")

    if item == 'done':
        break  # Exit the loop if the user is done ordering
    elif item in menu:
        total += menu[item]  # Add the price of the selected item to the total
        print(f"{item} added to your order. Your total is now ${total:.2f}")
    else:
        print("Invalid item. Please choose from the menu.")

print(f"Your total bill is ${total:.2f}")
Menu
burger  $3.99
fries  $1.99
drink  $0.99
burger added to your order. Your total is now $3.99
fries added to your order. Your total is now $5.98
drink added to your order. Your total is now $6.97
drink added to your order. Your total is now $7.96
drink added to your order. Your total is now $8.95