4 transportation exercise Car Rental, small error little advice please


#1



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


it gives me an error by stating that
Oops, try again. It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days.


to return the cost value of the days chosen


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


#2

you don't return cost when you rent the car for 1 or 2 days


#3

could you help me out?

i added this but keep getting no where, i tried adding >=1 and didnt work, could you help me out

elif days >=0:
cost


#4

can you post your full code? if you need to return something, use return keyword


#5

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

#6

now you only return cost for 2 days or less

How would you go about return the cost regardless of the numbers of days?


#7

i'm stuck i really need a hint please


#8

personally from this code:

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

i would just add an else for the remaining days, and return cost


#9

now i get this
It looks like rental_car_cost returns None instead of the correct amount (100) for 3 days.

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

#10

place the last return cost outside the elif clause.


#11

thank you it worked , sorry for giving you a headache


#12