#1

Hi,
Here is my code :
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):
cost = 40 * days
if days >= 7:
cost -= 50
elif days >= 3:
cost -= 20
return cost

def trip_cost(city, days):

return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)

Every time I'm getting this error : Oops, try again. rental_car_cost(1) returned None instead of the correct value 40
and I'm not sure why.

I have searched and altered my code few times and I just can't make it work.

#2

try this

def rental_car_cost(days):
total = days * 40
if(days >= 3 and days <= 6):
elif (days > 6):
else:

#3

Thank you very much that worked fine.
Bit annoyed as I don't understand why it worked on the previous stages of the exercise.
Thanks again.Need to dig in to Python.

#4

I could not let it go. I was testing other options and this worked for me and it makes more sense ( to me):
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):
if days >= 7:
return 40 * days - 50
elif days >= 3:
return 40 * days - 20
else:
return 40 * days

def trip_cost(city, days):

return rental_car_cost(days) + plane_ride_cost(city) + hotel_cost(days)

#5

Yep That is awesome the solution everyone provides here is to provide insight. Very good Idea to also come up with your own solution after analyzing those solutions