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


#1



def hotel_cost(nights):
    return 140 * nights
def plane_ride_cost(city):
    if city == "Charlotte":
        return 183
    elif city == "Tampa":
        return 220
    elif city == "Pittsburgh":
        return 222
    elif city == "Los Angeles":
        return 475
def rental_car_cost(days):
    price = 40 * days
    if days >= 7:
        price -= 50 
    elif days >= 3:
        price -= 20
    elif days > 1:
        return price


#2

your rental_car_cost function know only returns price when i am renting the car for two days. What about all the other days?


#3

so how to fix it? may be to put one more


#4

why do you have this condition:

elif days > 1:

i would remove it, and instead just return price


#5

i put it this way, still error

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


#6

sorry this way

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

#7

return should always be reached, currently this is only happening when i rent the car for: 3, 4,5 or 6 days. Not less then 3 or more then 7

why did you do:

price - 50

this will not update price, unlike price -= 50


#8

changed it - to -= still problem


#9


#10

what about return? Is it reached in all cases? Maybe change the indent of return? Or add multiply return statements, be careful: a function ends the moment a return keyword is reached

seems return isn't reached when i rent a car for less then 3 days or 7 days or more


#11

so please help - how to fix this for less than 3 days?


#12

well look:

if True:
   print True
elif False:
   print False
print "always"

i print "always" regardless of the conditions. Maybe you can do the same with your return price? You update price with the if/elif condition and then you return it afterwards? Not only if elif is true?


#13

This really helped me. :thumbsup: :thumbsup: Keep up the good work.


#14

Good to hear that i helped someone :slight_smile:


#15

thanks, i fixed it just put other var print, other than price


#16