HELP ERROR! trip_cost('Los Angeles', 7) raised an error: sum expected at most 2 arguments, got 3

#1

trip_cost('Los Angeles', 7) raised an error: sum expected at most 2 arguments, got 3

I don't understand why my code doesn't work. It gives an error that the sum is getting three arguments when I am only giving two. Can somebody please help me?

``````def hotel_cost(days):
Price_per_night = 140
Total = Price_per_night*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):
if days >= 7:
total = 40*days - 50
elif days >= 3 and days < 7:
total = 40*days - 20
else:
total = 40*days

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

#2

Hi @matss94 ,

Here, you passed three arguments to `sum` ...

``return sum(rental_car_cost(days),hotel_cost(days),plane_ride_cost(city))``

If you would like to use `sum` to total up some values, then enclose the values in a `list`, so that you can pass the list as a single argument ...

``return sum([rental_car_cost(days),hotel_cost(days),plane_ride_cost(city)])``

Note that the square brackets were used to create a list. But your code would be clearer if you used the `+` operator instead to add up the values ...

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