# Functions, Taking a Vacation, Putting it together

#1

Oops, try again. trip_cost('Tampa', 8) raised an error: sum expected at most 2 arguments, got 3

I just don't know what I am doing wrong... Can anyone help me out?

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

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):
rental = 40 * days
if days >= 7:
rental += (-50)
elif days >= 3 and days < 7:
rental += (-20)

return rental

def trip_cost(city,days):
return sum(rental_car_cost(days), hotel_cost(days), plane_ride_cost(city))``````

Actually it worked with this code: Isn't it possible to with sum(), but how?
def hotel_cost(days):
return 140 * days

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):
rental = 40 * days
if days >= 7:
rental += (-50)
elif days >= 3 and days < 7:
rental += (-20)

``return rental``

def trip_cost(city,days):
return (rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city))

#2

`sum()` is a built in function which can calculate the sum of an iterable (list, tuple)

so, knowing this, you could make a list, append what you want to get the sum of the list, call `sum()` on the list. Which is not really effective

#3

Okay, Thank you! I think it'll help me in further coding lessons!

#4