Taking a Vacation


Oops, try again. It looks like nothing was printed to the console!

The code is supposed to print the total trip cost. however it gets the above error message. Not sure where I am going wrong??

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):
    car_per_day = 40 * days
    if days >= 7:
        car_per_day -= 50
    elif days >=3:
        car_per_day -= 20
    return car_per_day
def trip_cost(city, days, spending_money):
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money
    print trip_cost("Los Angeles", 5, 600)


a function call executes the function, thus the function call should be place outside/after the function


Can you explain that another way please? not sure what you mean.


in python, what determines if something is nested inside a function?


I figured it out, the print function should be the last command to run. It was nested in the last command so did not print anything. I have moved it onto its own line as a stand alone function which has worked.

Thanks for the help :slight_smile:


some of the terms you you use are a bit confusing, first we have our function:

def trip_cost(city, days, spending_money):
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money)

then we have the function call:

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

this is named function call, the print statement only ensures that the returned value by the function is printed

stand-alone function? Its a function call, not a standalone function

No wonder you didn't understand:

because the terms i used are so different from yours


I am very new to python and the terms, I will make note and remember for next time!

Thank you.


Its confusing, but now i told you the terms, does my original reply make sense?


Yes, now it make perfect sense!

Again, thank you for your help today.


good :slight_smile:

For other people reading this, if the terms i use are confusing please say which terms i use are confusing, so i can clarify them and now where you get stuck at my instructions


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