Cant figure out this issue

#1

Taking a Vacation: 5. Pull it together

It gives me a lot of variantions which contain in trip_cost but i can't figure out what's wrong.
trip_cost('Tampa', 9) returned 1685 instead of the correct value 1790

return finishedsum

``````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
else:
return "Not Available"

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

def trip_cost(city, days):
finishedsum = hotel_cost(7) + rental_car_cost(7) + plane_ride_cost("Los Angeles")
return finishedsum``````

#2

your trip_cost function is a function you build to call all other functions in one go, which means you have to provide the function parameters as arguments for the function (host_cost and so on), so that you can provide the arguments to when you call trip_cost:

``finishedsum = hotel_cost(days) + // you do the rest``

this way, you can call trip_cost to calculate your total trip_cost (since trip_cost calls hotel_cost, rental_car_cost and plane_ride_cost)

#3

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