Taking a vacation : 4. Transportation


#1

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."

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


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


#2

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


#4

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