提问者:小点点

如何收纳带负号的数字列表?


我尝试了这个操作,但是它给了我这样一个错误:syntaxerror:非法表达式for augmented assignment

输入内容如下:-2 4-1

x_forces, y_forces, z_forces = 0
x_forces, y_forces, z_forces += map(int, input().split(' '))

共1个答案

匿名用户

这就是你要找的吗?

x_forces, y_forces, z_forces = 0, 0, 0
n = [i for i in map(int, input().split(' '))]

x_forces += n[0]
y_forces += n[1]
z_forces += n[2]

print(x_forces, y_forces, z_forces)