look at the error message ,everything i can't find the error ,we insert the value into function trip_cost('Los Angeles', 4) , and city will be string and days will be int type ,is that any knowledge i should know?
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
else :
return 123
def rental_car_cost(days):
total = days *40
if days >=7:
total=total-50
return total
elif days >= 3 :
total=total-20
return total
else :
return total
def prev_add(a,b):
return sum(a,b)
def trip_cost(city,days):
nights = days
hotel_cost_price = hotel_cost(nights)
rental_car_price=rental_car_cost(days)
prev_price = prev_add(rental_car_price,hotel_cost_price)
plane_ride_price = plane_ride_cost(city)
return sum(prev_price,plane_ride_price)
========================
error code :
trip_cost('Los Angeles', 4) raised an error: 'int' object is not iterable
===================
trip_costcall). I really hate the "friendly" interfaces that hide crucial detail.