Taking a vacation


#1

def rental_car_cost(days):
rental_cost = 40*days
if days >= 7:
return rental_cost - 50
elif days >=3:
return rental_cost - 20
else:
return rental_cost


#2

looks fine, do you have a question and/or error message?


#3

First, you don't use return until the last line.
Second, you don't need the else statement in this situation.
Third, following the if and elif lines, you should use rental_cost -= [whichever number].
-= (minus, equal). The return will follow the elif rental_cost-= #.


#4

there are multiply ways to solve the problem. @alice.beriozza code is also a way to solve the problem


#5

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