# Taking a Vacation: Transportation

#1

Transportation

I'm not sure what I've done wrong. Could someone please explain?

Error code: It looks like rental_car_cost returns 120 instead of the correct amount (100) for 3 days.

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

def plane_ride_cost(city): #Not sure why this isnt defined
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):
return 40 * days
if days <= 7:
return days - 50
elif days <= 3:
return days - 20``````

#2

If you read your function, from the top and downwards, what result do you get?

Each line there has some kind of purpose, each line corresponds to something that needs to be done in order to figure out the rental car cost. You should know, and/or be able to read what they do. Do that, and compare with what you intend it to do - what's the difference, and what change needs to be made?

Make sure that you first agree with that the result for that input should be 100, not 120, so that you're clear on how the rental car cost is supposed to be determined. Otherwise go find that out first.

#4

I'm very confused because I get the same error but this code return 100 not 120

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 rentalcarcost(days):
cost = 40 * days
if days >= 7:
cost = 40 * days - 50
elif days >= 3:
cost = 40 * days - 20
return cost
print rentalcarcost(3)

#5

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