Help needed with the error!


#1

Hello Folks,

I am getting the following error while trying to run the code. Can someone help?.

Oops, try again. rental_car_cost(1) returned None instead of the correct value 40

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 = 40 * days 
    if days >= 7:
        cost -= 50
    elif days >= 3:
        cost -= 20
        return cost 
def trip_cost(city, days):
    return hotel_cost(nights) + plane_ride_cost(city) + rental_car_cost(days)

#2

return cost is only reached when elif runs, return cost should always be reached, no matter how many days the car is rented, the answer to how to achieve to has to do with indention and nesting


#3

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