Been stuck on this for several hours


#1



When I save & submit my code, python tells me "Oops, try again. Make sure to define a function named trip_cost." However, I did define that function. I looked at other posts in the forum and they seem to have the same code I do. What did I do wrong?


days=raw_input("How many days are you planning to be away?")
nights=days
city=raw_input("Where will you be going?")

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 "Enter one of the following locations: Charlotte, Tampa, Pittsburgh, or Los Angeles."

def rental_car_cost(days):
    if days>=7:
        return (days*40)-50
    elif days>=3:
        return (days*40)-20
    elif days>0 and days<=2:
        return days*40
    else:
        return 0
    
    def trip_cost(days, city):
        return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)


#2

You aren't creating that function. That function is only created when you call rental_car_cost because that's where you put it. It also won't be accessible from outside rental_car_cost since it only exists inside rental_car_cost


#3

A post was split to a new topic: Plane ride


#5

Where you wrote def trip_cost(days, city) you indented too much. Right now python thinks that trip_cost is inside the rental_car_cost because you indented it, so all you have to do is take away the indentation on that line.


#6