Error for the spending_money argument


#1



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



I don't know why it doesn't accept this way I implemented the argument spending_money. It raised the return value ridicilously high up. This is the code:


Replace this line with your code. 
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):
    cost = 40 * days
    
    if days >= 7:
        cost -= 50
        return cost
    elif days >= 3:
        cost -= 20
        return cost
    
    return cost

def trip_cost (city, days, spending_money):
    extra = spending_money * 40
    return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + extra


#2

Be sure to use the variable you define as the parameter.

Where is this asked for in the instructions?


#3

Well I've also tried this solution, but the same problem occurs.

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

#4

Where is the * 40 coming from? That is not in the instructions. It should be a single value, like 600.

Eg.

print trip_cost("Tampa', 7, 600)

#5

A post was split to a new topic: This one is not working


#8

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