我在代码学院做一个项目,我必须制作一个程序来增加所有的假期成本(如旅行、城市等)。我不确定我的代码有什么问题。
def hotel_cost(nights):
return nights * 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):
if days < 3:
return 40 * days
elif days >= 3 and days < 7:
return days * 40 - 20
elif days >= 7:
return days * 40 - 50
def trip_cost(city,days):
city = plane_ride(city)
days = rental_car_(days) + hotel_cost(nights)
return total_cost(city + days)
此外,关于如何使我的代码不那么冗余和干净的任何建议。