Pull it togther bug!


#1



that's my code , but when i click save it says : "Oops, try again. Make sure to define a function named trip_cost. "


I think my code is correct , am i right ?


def hotel_Cost(nights):
    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(days,city):
    return rental_CarCost(days) + hotel_Cost(days) + plane_Ride_Cost(city)


#2

HI this line

def trip_Cost(days,city)

you wrote trip_Cost instead of trip_cost


#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":
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(days,city):
return rental_car_cost(days) + hotel_cost(nights) + plane_ride_cost(city)

giving me error says " Oops, try again. trip_cost('Pittsburgh', 5) raised an error: unsupported operand type(s) for -=: 'str' and 'int' ":


#4

did this but now it gives me another error


#5

this line

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

hotel_cost(nights) you should put days instead of night


#6

Did it and now gives me that error :"Oops, try again. trip_cost('Tampa', 7) raised an error: unsupported operand type(s) for -=: 'str' and 'int'
"


#7

Then here

def trip_cost(days,city):

put first city then days like that

def trip_cost(city, days):

#8

wow. it worked , ty a lot


#9

There isn't a bug. You just have to remember to use the hotel_cost function with the day argument.


#12

#Here's the code bro. I'm stucked too about 2 hours after I got this right code and can't find whole code in the discussion. Hope it'll help.
def hotel_cost(nights):
    # hotel costs $140/night
    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
    else:
        return "please pick a city"

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

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