HELP! Not sure why code not working 4/7


#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):
cost = days * 40
if days >= 7:
cost -= 50
elif days >= 3:
cost -= 20
return cost

"It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days."

Thanks in advance for any help!


#2

Well, you posted code without proper formatting and I am not able to check if all indentations are correct.

I guess that this is your code:

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

If so, the problem is that your function return is nested inside elif block. It means that your function will return anything only if 2 < days < 7.

You have to move your return statement one level of indentation down:

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

#3

thank you I shall try that out already checked the indentation wasnt aware of the return though!


#4

Thanks worked I really appreciate it


#5

You're very welcome :smiley: