Someone else asked a similar question but I don't understand the explanation of "The return statement causes your function to exit and hand back a value to its caller." What is a caller and what value does it hand back? I'm doing codecademy and this is what has me stumped.
def tax(bill):
"""Adds 8% tax to a restaurant bill."""
bill *= 1.08
print "With tax: %f" % bill
return bill
def tip(bill):
"""Adds 15% tip to a restaurant bill."""
bill *= 1.15
print "With tip: %f" % bill
return bill
meal_cost = 100
meal_with_tax = tax(meal_cost)
meal_with_tip = tip(meal_with_tax)
Why do you need "return bill" and what is the difference between "return bill" and just "return"? If I get rid of the first "return bill" there is an error. I feel like "return" resets the value of "bill". If that's the case shouldn't it still work? The def tip(bill) should take the value of bill from the first part and use that instead of 100. It won't be right (because it's doing 115% of 108% instead of 115% of 100%) but it shouldn't come up with an error.