Rental Car Problem


#1



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


I get following Error Code:
Oops, try again.
It looks like rental_car_cost returns 120 instead of the correct amount (100) for 3 days.


I am totally stuck on this part. everything runs smooth exept the Rental Car part. Can somebody help me please. I am clueless.


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


#2

These lines:

Have no effect at all

Your function is therefore equivalent to:

def rental_car_cost(days):
    return 40*days

Consider what they were meant to do and how to do that


#3

Do you have an advice or solution, how to get pass this problem?


#4

I would ask myself why those lines would have an effect, whatever that reason is, it isn't happening and that's what to look at and reconsider how it's done


#5

def rental_car_cost(days):
if days >= 7:
return days * 40 - 50
elif days >= 3:
return (days * 40) - 20
else:
return days * 40

This solved it for me. Thanks for your poke


#6

  def rental_car_cost(days):
        if days >= 7:  
            return days * 40 - 50
        elif days >= 3:
            return (days * 40) - 20
        else:
            return days * 40

#7

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