Pull it together


#1

why is this wrong?
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):
cost = 40*days
if days >=7:
cost -=50
elif days >=3:
cost -=20
return cost
def trip_cost(days,city):
return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days)


Pull it together : A little adjustment that Worked!
#2

I am getting this as a response:
Oops, try again. trip_cost('Los Angeles', 0) raised an error: cannot concatenate 'str' and 'NoneType' objects


#3

Hi this part

def trip_cost(days,city):

Try to switch the argument first write city then days
like that

def trip_cost(city, days):

#4

thanks easy to over look something like that


#5

Hi, could you explain why it works after switching the input arguments in the trip_cost() function?


#6

It has to do with the order in which the values appear in the function call expression.

print trip_cost("Charlotte",6)

In the first example above, days will be "Charlotte", and city will be 6. Not exactly what we planned for.