Question about Transportation


#1



https://www.codecademy.com/courses/python-beginner-P5YtY/1/4?curriculum_id=4f89dab3d788890003000096


I figured it out, but I had a code before I switched my approach and I can't figure out why it didn't work. An error gets thrown saying my code returns None.


It should result in exactly the same thing, should it not?


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


#2

Remember to return the undiscounted amount at the very end of your function.

return total

#3

Thanks. I was thinking of it as only the if statement and that everything would be covered, I forgot that that they only applied to discounts and so I needed the original total.


#4

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