This is my code. I have an error: trip_cost('Tampa', 9) raised an error: unsupported operand type(s) for -: 'str' and 'int' def hotel_cost(days): return 140*days 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=days*40 if days >=7: return cost-50 elif days >=3: return cost-20 else: return cost def trip_cost(days,city): return hotel_cost(days)+rental_car_cost(days)+plane_ride_cost(city) This is work code from another topic def hotel_cost(days): return days*140 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): rent = 40*days if days >= 7: return rent - 50 elif days >= 3: return rent - 20 else: return rent def trip_cost(city,days): return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) And it works. What is wrong with my code. I dont understand. Please, help me to understand. p.s. sorry for spaces)
Hi this line
put first the city then the days in the ()
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.