# Lesson 8. Taking a vacation, Hey, you never know

#1

Apparently trip_cost only takes 3 arguments when the exact instructions say to add another argument

Oops, try again. trip_cost should take exactly 3 arguments!

``````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:
"Stay home"

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

def spending_money(misc):
50 * misc
return misc

def trip_cost(city, days):
return sum([rental_car_cost(days), hotel_cost(days), plane_ride_cost(city)])
total = sum
return Sum + spending_money``````

#2

``````def trip_cost(city, days, spending_money):
cost_list = [rental_car_cost(days), hotel_cost(days), plane_ride_cost(city), spending_money]
total_cost = sum(cost_list)

trip_cost() takes three arguments: city, days, spending_money.

The list should have: rental_car_cost(days), hotel_cost(days), plane_ride_cost(city), spending_money

sum() is one of Python's built-in functions. Remove the first "return" keyword. Assign the sum to "total" variable. Add spending_money to the list. Finally, return the total.

#3

I understand that but why was i not told in the instructions to make a list especially since list weren't even covered yet?

#4

I'm very new to this but I think this is how you're intended to do it.

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

#5

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