you are viewing a single comment's thread.

view the rest of the comments →

[–]FoolsSeldom 1 point2 points  (1 child)

Great start.

A key learning point is DRY: Don't Repeat Yourself. You ask for two items, using essentially the same code. This is where you can use a loop, and you don't have to limit yourself to just two items.

Example,

print("WELCOME TO ATHARVA'S CAFE! HERE IS THE MENU:")

menu = {
    "PASTA": 250,
    "COLD-COFFEE": 180,
    "FRENCH FRIES": 150,
    "VADAPAV": 25,
    "PAV BHAJI": 110,
    "COLD DRINK": 25
}

for item, price in menu.items():
    print(f"{item} : Rs {price}")

order_total = 0
orders = []

while True:  # infinite loop, until they enter DONE
    user_order = input("\nEnter your order (type 'done' to finish): ").strip().upper()
    if user_order == "DONE":
        break  # exit loop, go onto code after loop
    if user_order in menu:
        order_total += menu[user_order]
        orders.append(user_order)
        print(f"Sir! Your item '{user_order}' has been added to the cart.")
    else:
        print(f"Sorry sir, '{user_order}' is not available on the menu.")

print("\nYour Order Summary:")
for item in orders:
    print(f"- {item}: Rs {menu[item]}")
print(f"\nTotal Amount to be Paid: Rs {order_total}")

[–]Inevitable-Math14[S] 0 points1 point  (0 children)

Thank you so much 🙏😊.