Plan your trip! (nothing was printed to the console!)


#1

I am getting this error
nothing was printed to the console!

Did I miss something?

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):
    total = 40*days
    if days >=7 :
        total -= 50
    elif days >= 3:
        total -= 20
    return total  
def spending_money():
    return spending_money

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

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

#2

a function only executes when called, there are no function calls in your case

if you want to print what is returned by a function add a print keyword before the function call


#3

Well, the user tried to make a function call, but buried this statememnt in a function, so it did not execute ...

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

@objectsolver83948 , consider the indentation of the above statement.


#4

i missed it

@objectsolver83948, the function call should be outside the function, since the call will execute the function, and you should indeed consider the indention


#5

sorry, i don't get it. I tried to make a function call outside the function but I got this error instead.

Traceback (most recent call last):
File "python", line 27, in
File "python", line 25, in trip_cost
File "python", line 17, in rental_car_cost
TypeError: unsupported operand type(s) for -=: 'str' and 'int'

Thank you.


#6

from the instructions:

After your previous code, print out the trip_cost( to "Los Angeles" for 5 days with an extra 600 dollars of spending money.

see the order? city first, then days and finally spending money. this should be the order of your arguments and parameters


#7

you indented wrong put your print line all the way to the left


#8

Got it. thanks! It never occured me at all.


#9

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