Transportation


#1

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

Can anybody help me with my code?The error says"Oops, try again. Did you create a function called rental_car_cost?"


#2

Hi @sm0423,

This statement is indented too much, making it part of the elif block ...

return cost

#3

why does this line:

def rental_car_cost(days):

have on space indention?

if the car is rented one or two days, no cost is returned


#4

@stetim94 I did not get you.


#5

well, if the car is rented for 1 day rental_car_cost should return 40, and 80 for 2 days. In your case, None (the default) is returned given no return keyword is reached


#6

So what do i do for it to return 40 or 80 for 1 or 2 days respectively?


#7

Oh,i got it.I just added an else statement at the end asking it to return cost.Thank you for your help.


#8

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