Taking a Vacation (Transportation)


#1

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

What is wrong with this code.
Error: Oops, try again.
It looks like rental_car_cost returns None instead of the correct amount (100) for 3 days.
Help me guys


#2

Hi
your return is inside the else so it is never reached if days < 3. You should
1) remove the `else` because there is no discount in the case where days < 3 and
2) place the return at the same indentation as the line `cost = 40 * days`
Cheers


#3

Thanks thebelgian1.:grin: