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


#1



Hi there. I cannot understand for the life of me why my code is giving me this error. Please see below.


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


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


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


#2

Here:

is where the error points to. You should do:

cost = days*40 #Cost per day rental is $40

#4

actually used this instead

def rental_car_cost (days):
cost = 40 * days

if (days >= 7):
   return cost - 50

elif (days >= 3):
   return cost - 20

else:
    return cost

#5

Thank you both for your help! It worked.


#6

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