# 4/7 Stuck

#1

``````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"

#2

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

#3

Now it throws the error "Oops, try again. It looks like rental_car_cost returns instead of the correct amount (40) for 1 days." But it did change the error so it did something.

#4

This line: (last line of rental_car_cost function)

``return rental_cost_car``

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

#5

140 not 40 if you look at it

#7

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!

#8

haha yeah i know. I fixed it.

#9

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

#10

``````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

#11

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

#12

#13

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``````

#14

Now your code is not indented at all?

#16

just edited the code, thank you for you patience.

#17

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

#18

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.

#19

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

English isn't my native language either

#20

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.