Messed Up do not reply


#1



https://www.codecademy.com/en/courses/python-beginner-P5YtY/1/4?curriculum_id=4f89dab3d788890003000096


Oops, try again. trip_cost('Tampa', 0) raised an error: cannot concatenate 'str' and 'int' objects


no error message


Replace this line with your code.


#2

code: def hotel_cost (nights):
return 140 * nights
def plane_ride_cost (city):
if "Charlotte" == city:
return 183
elif 'Tampa' == city:
return 220
elif 'Pittsburgh' == city:
return 222
else:
return 475
def rental_car_cost (days):
if days >= 7:
return days * 40 -50
elif days >= 3:
return days * 40 -20
else:
return days * 40
def trip_cost(days, city):
return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost (days)


#3

your function arguments and parameters are positional, so when the exercise validates your function works correctly by calling the function, the first is argument is Tampa which get passed into the first parameter days, and 0 will be passed into city.

hotel_cost can't handle Tampa as argument, same for plane_ride_cost and rental_car_cost


#4

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