rental_car_cost returns None instead of the correct amount (40) for 1 days


#1

Oops, try again.
It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days.

here is my code:

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

#2

Hi, @bitplayer38409 ,

Because your code is not formatted, it is difficult for other users to read and debug it. As code is being posted, you can format it by selecting it, and then by clicking the </> button above the editing area. This will enable us to see important details, such as the indentation and underscores.

Since we cannot see your indentation, we need to make an educated guess regarding the problem.

You probably have your indentation configured as follows ...

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

That would make the return statement part of the elif block, in which case it would only execute when days is between 3 and 6, inclusive. If that is the case, remove one level of indentation from this statement ...

return cost

#3

Thank @appylpye,Thank you very much.