8.4 Transporation


#1



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


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

idk where was my mistake,
i think that the problem.


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 :
        return cost -50
        
    elif days <= 3 :
        return cost - 20
    
    else :
        return cost


#2

Perhaps it is syntax or unexpected patterms. Who knows? What if we went with,

    cost = 40 * days
    if days >= 7:
        cost -= 50
    elif days >= 3:
        cost -= 20
    return cost

#3

thank you,
i just figured out what my mistake was,
thank you for your help too

the only mistake was
elif days <= 3 :

the right code to write is

elif days >= 3 :

and then! it works!


#4

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