# 5/7 Pull it together [unsupported errand types)

#1

My code:

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

def rental_car_cost(days):
if days >= 7:
return days*40-50
elif days >= 3:
return days*40-20
else:
return days*40
def trip_cost(days,city):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)

Error code returned to me:
Oops, try again. trip_cost('Pittsburgh', 5) raised an error: unsupported operand type(s) for -: 'str' and 'int'

After experimenting, I found out the error lies in the order of arguments and the correct order should be city followed by days. Could anyone tell me why must the order of the arguments be in that specific manner?

Thanks!

#2

With

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

you have defined a trip_cost function
which takes 2 parameters days and city

If you call this trip_cost function
trip_cost()
you will have to provide 2 arguments a number Value and a string Value
like
trip_cost(5,'Pittsburgh')

PS.
As you do not have an < escape > in your plane_ride_cost function,
when the city-name is wrongly put in
you have to be carefull.

# =====

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

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

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

#Error code returned to me
print trip_cost(5,'Pittburgh')

Error when city-name is NOT correct
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'