# 4. Transportation

#1

It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days

What am I doing wrong?

``````def hotel_cost(nights):
return 140 * nights
def plane_ride_cost(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):
rent_cost = 40 * days
if days >= 7:
return rent_cost - 50
elif days >= 3:
return rent_cost - 20``````

#2

Hi, @tufaan ,

You need to specify what to `return` if the car is not rented for `3` or more days.

#3

The problem is, you forgot to write the else statement.

#4

Hi @tufaan,

Just completed this task, as from what I can see here you're missing your else statement.

Simply put:

else:
return rent_cost

Hope this helps

#5

def hotel_cost(nights):
return nights*140
def plane_ride_cost(city):
if city=="Charlotte":
return 183
elif city=="Tampa":
return 220
elif city == "Pittsburgh":
return 222
elif city=="Los Angeles":
return 475
else:
return False
def rental_car_cost(days):
return 40*days
if days>=7:
return 40*days-50
elif 3<= days <7:
return 40*days-20
else :
return 40*days
whts prob in this code..??itz just showing k on day 3 the rent is 120 and not 100 in d erroe

#6

what am i doing wrong?

def hotel_cost(nights):
#per night cost is \$140
return nights*140
def plane_ride_cost(city):
if city =="Charlotte":
return 183
elif city== " Tamba":
return 220
elif city== "Pittsburgh":
return 222
elif city == "Los Angels":
return 475
def rental_car_cost(days):
rental_cost=40*days
if days>=7:
rental_cost-=50
elif days>=3:
rental_cost-=20
else:
return rental_cost

#7

i got it now

def hotel_cost(nights):
#per night cost is \$140
return nights*140
def plane_ride_cost(city):
if city =="Charlotte":
return 183
elif city== " Tamba":
return 220
elif city== "Pittsburgh":
return 222
elif city == "Los Angels":
return 475
def rental_car_cost(days):
rental_cost=40*days
if days>=7:
return 40*days-50
elif days>=3:
return 40*days-20
else:
return rental_cost

#8

def rental_car_cost(days):
everyday_rent = 40 * days
if days >= (7):
return everyday_rent - 50
elif days >= (3):
return everyday_rent - 20
else:
return everyday_rent #not mentioned in the instructions

#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.