你题目的解答代码如下:
def calcx(operations):
x = 0
for op in operations:
if op=="--X" or op=="X--":
x = x-1
elif op=="++X" or op=="X++":
x = x+1
return x
operations = ["--X","X++","X++"]
print(calcx(operations))
如有帮助,望采纳!谢谢!