Transportation Help


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

Replace this line with your code. 
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 rental_car_cost


your return the function, you should return the cost

make sure that you return cost also after you applied discount


In your function, you return rental_car_cost. This variable holds the function itself, maybe you meant to return the variable cost?

Also, the body of an else clause only executes when none of the conditions in the if or elif statements above are true. For example, in the following code, "Hooray!" is only printed when x is not 5 and x is not 10. If x is either of those values, then "fiver" or "dime" are printed out instead. Regardless of the value, only one print statement ever happens.

if x == 5:
elif x == 10:


In this rental_car_cost you specified elif condition whcih can be suffice if days are greater then 7 in which they will give both the discounts. I think we have to give a range whcih suggest more then 3 but less then 7. Please correct me if wrong.

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


Return both the total and the cost at the end of the code to make it work.


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