Hey, you never know!


#1



https://www.codecademy.com/courses/python-beginner-P5YtY/1/5?curriculum_id=4f89dab3d788890003000096

error: Oops, try again. trip_cost('Los Angeles', 2, 0) raised an error: unsupported operand type(s) for +: 'int' and 'builtin_function_or_method'

i think the code is right but im missing something.

def hotel_cost(days):
    return 140*days

def plane_ride_cost(city):
    if city == "Charlotte":
        return 183 
    if city == "Tampa":
        return 220 
    if city == "Pittsburgh": 
        return 222
    if city == "Los Angeles":
        return 475

def rental_car_cost(days):
    cost = days*40
    if days >= 7:
        cost -= 50
    elif days >= 3 :
        cost -= 20
    return cost 

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


#2

what is the function of this line:

spending_money = sum

?
sum is a built in function, which explains integer + function object error


#3

def hotel_cost(days):
    return 140*days

def plane_ride_cost(city):
    if city == "Charlotte":
        return 183 
    if city == "Tampa":
        return 220 
    if city == "Pittsburgh": 
        return 222
    if city == "Los Angeles": 475

def rental_car_cost(days):
    cost = days*40
    if days >= 7:
        cost -= 50
    elif days >= 3 :
        cost -= 20
    return cost 

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

new error: Oops, try again. Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Take a look at the console window for the error message from the interpreter.


#4

i asked a question, please answer


#5

i want the sum of spending money


#6

but spending_money will be a integer, telling you how much spending money people have on holiday, why do you need the sum of this?


#7

Instructions
Modify your trip_cost function definition. Add a third argument, spending_money.
Modify what the trip_cost function does. Add the variable spending_money to the sum that it returns.


#8

add spending_money to the sum it returns, it refers to this:

return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)

this is the sum your function returns, all you need to do is add spending_money to it (using +


#9

Oops, try again. plane_ride_cost('Los Angeles') returned None instead of the correct value 475


#10

impossible to tell without an updated version of your code, i am helping you, but i am not a magician.


#12

sorry :smiley:

def hotel_cost(days):
    return 140*days

def plane_ride_cost(city):
    if city == "Charlotte":
        return 183 
    if city == "Tampa":
        return 220 
    if city == "Pittsburgh": 
        return 222
    if city == "Los Angeles": 475

def rental_car_cost(days):
    cost = days*40
    if days >= 7:
        cost -= 50
    elif days >= 3 :
        cost -= 20
    return cost 

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

#13

you still have this line:

sum = spending_money

despite my recommendation to get rid of it


#14

Now its working Thanks! ;D


#15