Help with 4/7


My code is this
def rental_car_cost(days):
cost = days * 40
if days >= 7:
return cost - 50
elif days >= 3:
return cost - 20
return cost

but I get this in reply
It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days.


please copy paste your code again and apply format:

so indent shows


‘’‘def rental_car_cost(days):’’’
’’’‘cost = days * 40’’’
’’‘if days >= 7:’’’
’’‘return cost - 50’’’
’’‘elif days >= 3:’’’
’’‘return cost - 20’’’
’’‘return cost’’’

idk I tried indenting


cost is currently not returned when the car is rented for one or two days, because you placed the final return cost inside the elif body

you could add else and then return cost for all the remaining scenarios by adding return cost to else


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