I NEED HELP! Problem with 4.Transportation


#1

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

Oops, try again. It looks like rental_car_cost returns 120 instead of the correct amount (100) for 3 days.

I did as it says to and I still can't figure this out! I've read so many topics on this and none help me! I always get error messages!

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

#2

Hi its missing the else statement like the error says

Oops, try again. It looks like rental_car_cost returns 120 instead of the correct amount (100) for 3 days.


#3

I don't know what to put in an else statement.


#4

You just need to return

 return 40 * days

#5

i have this: elif days >= 3 and < 7:
return rental_car_cost - 20

wouldn't this also be correct, since i put in the else statement the range in between your possibility to get a deduction of 20$?


#6

Hi this part

elif days >= 3 and < 7:

Its missing Something before < 7 put days like that days < 7


#7

yes i wrote that first, but that didn't work. It ran the code but i got this:

Oops, try again.
It looks like rental_car_cost returns 120 instead of the correct amount (100) for 3 days.

my full code is:

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


#8

This part

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

you should remove 50 and 20 to 40 * days so try to do it like that

First inside your function create a variable and save 40 * days and then in your if and elif statement you just have to put the variable - 50 or 20. LiKe that

def rental_car_cost(days):
    rent_car = 40 * days
    if days >= 7 : 
        return rent_car - 50 
   ............

#9

Here's the code that worked for me:
indent preformatted text by 4 spaces
def rental_car_cost(days):
if days >= 7:
return 40 * days - 50
elif days >= 3:
return 40 * days - 20
else:
return 40 * days


#10


def rental_car_cost(days):

if days >= 7:
    return 40 * days - 50

elif days >= 3:
    return 40 * days - 20
else:
    return 40 * days