This is my code:
def trip(nights):
return 140 * nights
def plane_cost(ride):
if ride == "London":
return 220
elif ride == "Rome":
return 200
elif ride == "Glascow":
return 185
def car_rental(days):
cost = 20 * days
if days >= 7:
cost = cost - 25
if days >= 3:
cost = cost - 10
return cost
def tripcost(ride, days, spending_pounds):
trip(days) + plane_cost(ride) + car_rental(days) + spending_pounds
print ("London", 5, 500)
Was wondering why the word tripcost
(marked in bold) was shown to be a syntax error when I loaded it in idlE?
尝试from __future__ import print_function
添加脚本的开头,并更改print(tripcost("London", 5, 500))
print tripcost("London", 5, 500)
上的print(tripcost("London", 5, 500))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.