Taking a vacation : 4. Transportation


Help please! I had been stuck on this code for ages, the notifications keep saying

"It looks like rental_car_cost returns 120 instead of the correct amount (100) for 3 days."


def hotel_cost(nights):
    return 140*nights

def plane_ride_cost(city):
    if city == "Charlotte":
        return 183
    if city == "Tampa":
        return 220
    if city == "Pittsburgh":
        return 222
    if city == "Los Angeles":
        return 475

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


a function ends the moment a return keyword is reached, so your function ends here:

return 40*days

the rest of the code is never reached, so the discount is never applied


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