# 4/7? I Have No Clue

#1

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

I Fixed it to this and I have no clue how my code is wrong????

#2

Looks correct, lets see...

It returns `None` wth 1 sec.

#3

I see why, it really is simple. Once you remember that your if/else statement will not execute the else statement unless it falis all other checks.

Change it to

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

#4

Hi,
new to this community. with above code I am getting error saying: It looks like rental_car_cost returns None instead of the correct amount (100) for 3 days.

#5

Try this

def hotel_cost (nights):
cost = 140
return cost * nights

def plane_ride_cost (city):
if city == "Charlotte":
return 183
elif city == "Tampa":
return 220
elif city == "Pittsburgh":
return 222
else:
return 475

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

# note the greater than equal to...

#6

That did not work either, Do you think the system is making a mistake because I do not see the problem.

#7

Your code must be bugged otehr than that, I cope/pasted my code right into 4/7 and it worked.

Here is the whole section,

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

def plane_ride_cost(city):
city = city.lower
if city == 'charlotte':
plane = 183
elif city == 'tampa':
plane = 220
elif city == 'pittsburgh':
plane = 222
elif city == 'los angeles':
plane = 475
else:
print 'You have entered an invalid city name'

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

print(rental_car_cost(5))``````

#8

Thanks for your reply. BUt didn't understand the 'plane' in second function. What was that?

#9

Got error plane_ride_cost('Charlotte') returned None instead of the correct value 183 for this code.

#10

Close and restart your browser, I literately just copy and pasted this code as is into the lesson and it works. So it has to be on your end some how.

#11

ive done this lesson before and i chose a different way that turned out to be correct
this way didnt work for me