I am getting error messages Oops, try again. trip_cost('Charlotte', 9) raised an error: global name 'plan_ride_cost' is not defined


#1

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
else:
return "null"

def rental_car_cost(days):
cost = 40*days
if days >= 7:
seven_discount = cost - 50
return seven_discount
elif days >= 3 and days <= 7:
three_discount = cost - 20
return three_discount
else:
return cost

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


#2

Sorry I have no got this working but it does not print to the console. The lessons says I have finished but it does not actually seem to do anything.


#3

Hi vamkam,

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

Compare plan_ride_cost(city) (current) with plane_ride_cost(city) (correct)


#4

Thank you. As soon as I posted i found that. However, the code does not ask me for any data in the console window and outputs nothing? Is this right?


#5

It's ok. You can manually test your code by doing something like:

print trip_cost("Tampa", 10)

and comparing with your own calculations. If the code passed and there are no errors in console, then your code is completely fine, so good job! :slightly_smiling: