 # 4/7 Stuck

``````def hotel_cost(nights):
# It costs \$140 per night
return 140 * nights

def plane_ride_cost(city):
# Cost varies based on 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 per days
price == 40 * days
if days >= 7:
price -= 50
elif days >= 3:
price -= 20
return rental_cost_car
``````

Its throwing the error “Oops, try again. An error was raised for rental_car_cost(1): local variable ‘price’ referenced before assignment”

this line:

``````price == 40 * days
``````

inside your rental_cost_car function, you use two equal signs, which means you compare price with 40 * days, but i think you want to assign a value, to price, use a single equal sign

Now it throws the error “Oops, try again. It looks like rental_car_cost returns <function rental_car_cost at 0x7f590153faa0> instead of the correct amount (40) for 1 days.” But it did change the error so it did something.

This line: (last line of rental_car_cost function)

``````return rental_cost_car
``````

you should return the price, not a non existing something.

140 not 40 if you look at it

Yes, that is quite mistaken because you calculated the amounts manually. That defeats the purpose of writing a computer program to perform the calculations for you!

haha yeah i know. I fixed it.

hello friends, im having trouble here:

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

File “python”, line 21
SyntaxError: ‘return’ outside function

``````def rental_car_cost(days):
cost = days * 40
``````

if you want your if, elif and else to be inside the function, make sure the indent is correct

thank you, it worked but bnow im getting this msg:

Oops, try again. It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days.

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

Oops, try again. It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days.

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

Now your code is not indented at all?

just edited the code, thank you for you patience.

I don’t understand, you where so close here:

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

all it needed, was a little indent:

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

yet, you manage to screw up big time

1 Like

Thank you very much, the problem is that English isnt my native language, and i ahd nbo ideia what the word “indent” meant. but now i do! thank you again.

Programming in python without knowing what indenting is, is going to be very tricky.

English isn’t my native language either Yeah i know, im really trying to learn this little things. This is my frist try at programming. I looked up where it would be easier to start and ended up here.

1 Like