What could be the problem as I keep getting this error " plane_ride_cost('Charlotte') raised an error: global name 'nights' is not defined" def hotel_cost(nights): return 140 * nights def plane_ride_cost(city): if city == "Charlotte": return 183 * nights elif city == "Tampa": return 220 * nights elif city == "Pittsburgh": return 222 * nights def rental_car_cost(days): rent= days * 40 if days >=7: rent= rent-50 elif days >=3: rent= rent-20 return rent def trip_cost(city, days): return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)
You use the nights variable in your function
plane_ride_costs but nights is not defined in this function.
And you only need to return the number, no calculation needed in
the prices for the places are fixed, they don't need to be multiplied with nights
After removing the multiplication with the nights the error I am getting is : plane_ride_cost('Los Angeles') returned None instead of the correct value 475
you forgot to add a elif to check if city could be Los Angeles
Thanks guys, the code is running perfectly now