Skip to the content.

1.4 Error Correction • 2 min read

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
fries added to your order. Your total is now $1.99
Invalid item. Please choose from the menu.
drink added to your order. Your total is now $2.98
Your total bill is $2.98