def hotel_cost(days):
return days*140
def plane_ride_cost(n):
if n == "Charlotte":
return 183
elif n == "Tampa":
return 220
elif n == "Pittsburgh":
return 222
elif n == "Los Angeles":
return 475
def rental_car_cost(days):
cost = 40 * days
if days >= 7:
cost-=50
elif days >=3 and days <7:
cost-=20
return cost
def trip_cost(city,days):
return rental_car_cost(days)+ plane_ride_cost(n)+hotel_cost(days)
I輸入上面的代碼,並獲得各種錯誤,其中之一是:無法解決碼錯誤
trip_cost('Tampa', 5) raised an error: global name 'n' is not defined
@Sayse通過編輯關於Code Academy的部分,您已經弄清楚錯誤的「糟糕,再試一次」部分來自哪裏。 –
@JonathonReinhart - 在這種情況下,應該刪除「糟糕,再試一次」。 – Sayse
@Sayse你讓事情變得更糟。這不是標準的Python異常消息。 –