I am getting this error but i couldn't find any can you please help me


#1



Replace this line with your code.


#2

can you copy paste your code to the forum so we can actually run the code?


#3

iam not so sure but try to refresh the page , i think you already did this has happened to me once


#4

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 = cost-50
    elif days >= 3:
        cost = cost-20
    
        return cost 
    
    
    
def trip_cost(city, days, spending_money):
        return plane_ride_cost(city) + hotel_cost(days) + rental_car_cost(days) + spending_money
      
       
       
        print trip_cost("Los Angeles" ,5 ,600)

#5

i tried that too but am getting the same error.


#6

your function call should be outside/after the function (hint: indention)


#7

yea i did but even after doing that it is showing me the error.
the error is trip_cost should take exactly three parameters: city, days and spending_money(in that order).
actually i gave the input in the same order i got the output value but i donno y it is showing like that.


#8

can i see an updated version of your code?


#10

the problem is in your rental_car_cost function, rental car cost should always return cost of renting a car, currently its only doing this when renting the car between 3 and 7 days, not for the other cases


#12

you can revisit the exercise, here is some code:

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

print rental_car_cost(1)
print rental_car_cost(8)

which shows your function isn't working correctly, both function calls print None while they should print 40 and 270


#13

thank yu. i got the output


#14

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