作为练习练习,我试图从用户那里获得五个数字并使用while循环返回所有五个数字的总和.我设法收集了五个数字,但总和不是由我的代码提供的(我得到一个数字,但它始终是最后一个数字的两倍).我认为问题在于我使用+ =.
x = 0
while x < 5:
x += 1
s = (int(raw_input("Enter a number: ")))
s += s
print s
Run Code Online (Sandbox Code Playgroud) python ×1