Try to use dictionary make it short


#1

def hotel_cost(nights):
return 140*nights
def plane_ride_cost(city):
citys = {"Charlotte":183,"Tampa":220, "Pittsburgh":222,"Los Angeles":475}
return citys[str(city)]
def rental_car_cost(days):
if days >=7:
return days *40 - 50
elif 3<=days<7:
return days*40 -20
else:
return 40*days
def trip_cost(citys,days):
return rental_car_cost(days) + hotel_cost(days) +plane_ride_cost(city)

it says global variable "city" is not defined, what's the logic behind this?thx


#2

Actually, I found what's going wrong, I add citys instead city in the function, Sorry for brother you guysXX