Can't call function properly in python due to unknown reasons -
after compilation error:
traceback (most recent call last): file "python", line 29, in <module> file "python", line 26, in trip_cost typeerror: 'int' object not callable
the following code expenditure calculation application wrote. there 4 arguments passing inside trip_cost function in end 4 parameters defined in function definition.
def hotel_cost(nights): return 140 * nights def spending_money(money): return money def plane_ride_cost(city): if city == "charlotte": return 183 elif city == "tampa": return 220 elif city == "pittsburgh": return 222 elif city == "losangeles": return 475 def rental_car_cost(days): cost = 40 if days >= 7: return (cost * days - 50) elif days >= 3 < 7: return (cost * days - 20) elif days < 3: return (cost * days) def trip_cost(city,days,spending_money): total_trip_cost = plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days) + spending_money(spending_money) return total_trip_cost print trip_cost("losangeles",5,600)
your local variable spending_money
over-writing function spending_money()
in trip_cost
function's scope.
since spending_money()
function doesn't anything, add directly.
Comments
Post a Comment