Pull it together

I keep getting an error message that says; “Make sure to define a function named trip_cost”, but I think i’ve done everything that the exercise asked for.

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):
return hotel_cost(days - 1) + plane_ride_cost(city) + rental_car_cost(days)

Try calling it yourself. If it’s there you can call it.

And then, if it’s not there, you can start out with a simple function that you call:

def hello():
    print('hello world')


You’d run that, verify that you’ve successfully defined a function. Then you’d start turning that into your other function one piece at a time, verifying that you haven’t yet broken it.

During this you may simply fix the issue, in which case you need to compare what was different and consider how you could have identified it yourself immediately.
Or you’d run into the same issue again, but this time it would be during a small change and you’ll be able to tell what that change was which breaks it.

See it as an exercise in comparison and debugging.