# Stuck at exercise "4.Transportation". Code seems correct

#1

I'm in the exercise "4.Transportation" from "Taking a Vacation"

It doesn't skip to the next lesson. The only error message is "Oops, try again. It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days."

I expected it to advance to the next lesson, as I see no error in the code.

``````def hotel_cost(nights):
return 140 * nights

def plane_ride_cost(city):
if city == "Charlotte":
return 183
if city == "Tampa":
return 220
if city == "Pittsburgh":
return 222
if city == "Los Angeles":
return 475
def rental_car_cost(day):
cost = 40
if day >= 7:
return cost * day - 50
elif day >=3:
return cost * day - 20``````

#2

@bitace31577

I think the problems come from here

If `day` is bigger or equal than 7, we return `cost` minus 50
If `day` is bigger or equal than 3, we return `cost` minus 20

It should look like this:

``````if day => 7:
return cost - 50
elif day => 3:
return cost - 20``````

#3

No it isn't.

The description of the problem says

Calculate the cost of renting the car:
Every day you rent the car costs \$40.
if you rent the car for 7 or more days, you get \$50 off your total.
Alternatively (elif), if you rent the car for 3 or more days, you get \$20 off your total.
You cannot get both of the above discounts.

So I presume it is the exact amount of days or a value bigger than it.

#4

@bitace31577

Ah right I was wrong, sorry for that mistake!

#5

No problem...
How do you format code to appear like that?

#6

@bitace31577

We format code like this

`````````
Replace this line with your code. Do not remove backtips
`````````

#7

I changed the code to match the instructions, where they say the argument for `rental_car_cost` should be `days`.

``````def hotel_cost(nights):
return 140 * nights

def plane_ride_cost(city):
if city == "Charlotte":
return 183
if city == "Tampa":
return 220
if city == "Pittsburgh":
return 222
if city == "Los Angeles":
return 475
def rental_car_cost(days):
cost = 40
if days >= 7:
return cost * days - 50
elif days >=3:
return cost * days - 20``````

And it in fact an effect, but now the error returned is "Oops, try again. It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days."

Which me leads to think the function was expected to be called somewhere in the code. I did it but still it the same error message presented above shows up in the screen.

In conclusion, I'm leaving that to someone to fix, that is the second bug I faced in codecademy, but the first one that prevents me from advancing in the course, which is a pity, because this was required by one of my professors from college as a complementary work.

#8

@bitace31577

That's what I did...

# If days is bigger or equal to 7

I will set `cost` to itself minus 50

# Otherwise if days is bigger or equal to 3

I will set `cost` to itself minus 20

# Now, out of my if/elif statement, I will return `cost`

which in final looks like this:

``````if days => 7:
cost -= 50
elif days => 3:
cost -= 20
return cost``````

Note to self: Everything is indented

#9

Didn't work, it goes all the same.
Anyway, thanks for the help, I hope they fix this real soon.
PS: `>=` is the right operator to "greater or equal"

#10

HI this part

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

``return cost * days``

with the same indent of if and elif statement

#11

HI this part

``````if days >= 7:
cost -= 50
elif days >= 3:
cost -= 20
return cost``````

will work if he saved the moltiplication 40 * days inside the variable cost like that

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