Plan Your Trip - not printing to console!


#1

I've been trying to figure this out but for some reason nothing gets printed onto the console. Can someone help me to point out the error?

def hotel_cost(days):
    return 140 * days

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

    print trip_cost("Los Angeles", 5, 600)

#2

you place the function call (which will execute the function) inside the function. Place the function call outside/after the function


#3

Why though? It does work, however why is this needed, could you please explain this. Doesn't it want to execute the function?


#4

functions are a block of code we can use repetitively by calling the function. By default, a function won't execute.

it? What is it? Can you please be a bit more specific?

the function is interpreted, but if we prompt the user for input, then its nice to call the function afterwards them to tell them how much there trip would cost, for which we need to call the function

for now, we assume they want to go for los angeles for 6 days with 500$ spending money. In a real life applications, this would be option menus


#5

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