Stuck @ Pull it together


#1


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

error:
Oops, try again. Make sure to define a function named trip_cost.

code to work

def hotelCost(days):
    return 140*days

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

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

def trip_Cost(days,city):
    return rentalCarCost(days) + hotelCost(days) + planeRideCost(city)


#2

Seems that you switched the arguments' positions in your function. So when Codecademy is testing your code, it is putting days in the cities spot and cities in the days spot.

Hope this helps! If not, feel free to leave a reply and I'll try to go more in-depth.


#3

i Switched days with city and still same error...

def hotelCost(days):
    return 140*days

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

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

 
def trip_Cost(city,days):
    return rentalCarCost(days) + hotelCost(days) + planeRideCost(city)

#4

you function name should be exact same what the instruction told you

Error:

Oops, try again. Make sure to define a function named hotel_cost


#5

Thanks! had me stuck for a day :open_mouth:


#6

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