What's wrong with my code?


I tried with different ways to have the answer, I think it was the short way to get it but I don't have any result with it. The 5 line it's the messy one. Any advice would be welcome, also if you take the time to explain me.

meal = 44.50
restaurant_tax = 6,75
tip = 15
cost = meal + ( meal * restaurant_tax) + ( meal * tip)
print cost


Well, I got this like a good answer:

Assign the variable meal the value 44.50 on line 3!

meal = 44.50
tax = 0.0675
tip = 0.15
cost_meal = meal + ( meal * tax )
total_cost = cost_meal + ( cost_meal * tip)
print total_cost

Python ~ Section: The meal Please Help me

Hey Python Scripters...

I have an problem with this code:

# Assign the variable total on line 8!

meal = 44.50
tax = 0.0675
tip = 0.15

meal = meal + meal * tax

print("%.2f" % total)

Can anyone help me, to tell whats wrong with my code ?...
I don't know what i must to do... can anyone help me ?...

I think thad i must write an variable on line 8... but it don't
work with my code, i don't know what i must to do.

Thanks, Jamie van Cadsand.


You forgot to assign the variable total, which the exercise asks you to assign. Thus, the code also raises an error when you print out the total, since it hasn't been defined.
Add this below "meal = meal + meal * tax":

total = meal + meal * tip

Also, from next time onwards, please open up a new topic, as it'll help us in replying faster, plus you get free badges from Codecademy :stuck_out_tongue: .


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.