# Taking a vacation help

#1

Taking a vacation help

Oops, try again. An error was raised for rental_car_cost(1): local variable 'cost' referenced before assignment

I need correct this, but i am not understanding what was happen. Someone can help me, pls ?

``````Replace this line with your code.

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

#2

here:

``cost == 40 * days``

two equal signs means: check if equal. Why would you do that?

#3

hotel_cost(nights):
return nights * 140
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
else: return "No prices"

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

Now the "If" and "elif" defines conditions for days >= 7 and >=3 repectively
but the else returns what happens when your days are below the 3 and 7..............

#4

Try < 3 for the first hree days
then a new elif to cover days 3-6 but you must use the "and" function to also filter less than 7

Like so:

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

#5

i think @javaninja78294 post was a post to help, not needing help

#6

What's even more bizarre is I thought I was replying to a different issue. Feel free to delete. Thanks.

#7

Yea, i thought you thought that Nah, its fine.

#8

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