4/7 Taking a Vacation, help!


#1

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

#2

can you post the whole code that you have


#3

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

#4

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


#5

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


#6

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


#7

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


#8

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


#9

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.


#10

Yes, it worked tnx!!!