4/7 Taking a Vacation, help!

Here is my code, I am unsure as to why it isn’t working. When executed, I receive the error message “Oops, try again. Did you create a function called rental_car_cost?”

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

can you post the whole code that you have

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

Try this code, it worked for me.

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

Problem is sorted, no worries! Just a simple indentation error.

1 Like

This worked for me after a long hard process trying to figure it out

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

This worked for me:

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

but it doesn’t actually return anything that is what i don’t understand

I don’t know if it’s what you mean by doesn’t return, but in my opinion, you don’t see the return, because you didn’t print it, if that’s what you meant. Like the return is actually returned but you just don’t see it if you don’t print it.

Yes, it worked tnx!!!