[solved] Hey, you never know! part 6/7


#1

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

When I "save and submit" it says: 'Oops, try again. trip_cost('Charlotte', 3, 0) raised an error: 'int' object is not callable'

What's the problem!!??


#2

Hi @boyzac2 ,

Because the code that you posted is not formatted, it is difficult for other users to read and debug it. After code has been pasted into the editing window for posting, you can format it by selecting it, and then by clicking the </> button above the editing area. Alternatively, you can place three backquotes on the line before the code and three backquotes on the line after the code. This will enable us to see important details, such as the indentation and underscores. If you use the backquotes, your code will be color-coded, making it especially easy to read.

You have this ...

return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_money()

The variable, spending_money represents an int, but you have followed it with parentheses, as if it were a function.


#3

Ooooh OK it was just the parentheses. It's working now. Thanks.