# Transportation

#1

My code seems to be similar to others that i've seen yet it still doesn't work.

I get this as an error: An error was raised for rental_car_cost(1): local variable 'cost' referenced before assignment

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

#2

say that cost is a variable

var cost = 40*days

#3

I don't think thats the correct way to define a variable in python.

#4

true, sorry

why do you have 2 equals ? (cost == 40*days) do you want to assign? or to compare?

#5

Two equals for assigning a value to a specific variable.

#6

no, you need only one equal to assign a value

#7

my bad that fixed it thanks

#8

im also having the same problem....how do u fix it???
my code is this-
def rental_car_cost(days):
cost == days * 40
if days >= 7 :
cost -= 50.0
elif days >= 3 :
cost -=20
else:
return 40 * cost

#9

I get this as an error: An error was raised for rental_car_cost(1): local variable 'cost' referenced before assignment

#10

you also have the same problem.

remove double equals.

cost = days *40

#11

then it says this-
It looks like rental_car_cost returns 1600 instead of the correct amount (40) for 1 days

#12

this is an error on the logic of your code. meaning that you are not doing the correct mathematical operations.

#13

I got this:sweat_smile:
def rental_car_cost(days):

``````cost=days*40
if days >= 7:
cost-=50
elif days >= 3:
cost-= 20
else:
cost``````

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

#14

you need to "return the cost"

on the last else

write "return cost"

#15

Thank you very much!