Unsupported operand type(s) for -: 'str' and 'int'


#1

Hey,
I am facing issues getting through this exercise as well.
The error that came up was
"Oops, try again. trip_cost('Los Angeles', 7) raised an error: unsupported operand type(s) for -: 'str' and 'int' .."
Below is my piece of code.

Any help is appreciated.

Thanking you in anticipation,
Shreyas


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 plane_ride_cost

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

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


Need help getting past this
#2

The local parameter is days. Call the function using that variable. nights is local to the hotel-cost function and does not exist in the calling scope of trip_cost.


#3

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