Pull it together


#1




The interpreter says that I have not defined a function called trip_cost . Can someone please help.


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


#2

Your fuction is inside a function, and that messes things up. Remove the indendations before your function trip_cost, and it will work.


#3

Your function trip_cost should be on the same indentation level as your other functions, :slight_smile:

def main_exampel():
    some main code
#On the same indentation level as main_example
def example():
    some code

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.