所以我在codeacademy的python教程中遇到了这个问题,
代码是这样的
def hotel_cost(days):
return days*140
Charlotte = "Charlotte"
Tampa = "Tampa"
Pittsburgh = "Pittsburgh"
LosAngeles = "Los Angeles"
def plane_ride_cost(city):
if city == Charlotte:
return 183
elif city == Tampa:
return 220
elif city == Pittsburgh:
return 222
elif city ==LosAngeles:
return 475
else:
return "not"
def rental_car_cost(days):
if days <3:
return days*40
if days >=3 and days<7:
return days*40-20
if days >=7:
return days*40-50
def trip_cost(city,days):
return hotel_cost(days)+rental_car_cost(days)+plane_ride_cost(city)
我再次意识到语法中的错误
def trip_cost(city,days):
return hotel_cost(days)+rental_car_cost(days)+plane_ride_cost(city)
但我没有足够的知识以任何可能的方式对其进行修改(我确实尝试过)
非常感谢所有查看此内容的人