#Rate my code
10 messages · Page 1 of 1 (latest)
food = []
def Discount(**kwargs):
price = kwargs.get("price", 0)
discount_price = price * 0.10
amount = price - discount_price
print(f"Discounted price: ₹{amount:.2f}")
def Tax(**kwargs):
price = kwargs.get("price", 0)
tax_amount = 2.65
total = price + tax_amount
print(f"Total after tax: ₹{total:.2f}")
while True:
name = input("Enter your food (Q to quit): ")
if name.upper() == "Q":
break
if not name.strip():
print("Invalid name. Try again.")
continue
try:
price = int(input(f"Enter {name}'s price: ₹"))
except ValueError:
print("Price must be a number.")
continue
food.append((name, price))
if price > 500:
Discount(price=price)
else:
Tax(price=price)
print("\n🧾 Final Invoice:")
for item in food:
print(f"- {item[0]}: ₹{item[1]}")
umm the biggest flaw in this code is that
final invoice won't show discounted/taxed price
Using dictionary could be a better approach here
Dunno havent analyzed lmao
Alright
ya
Happy to know mistakes to fix them!