擅长:python、mysql、java
<p>我想这就是你要问的:</p>
<p>使用for循环编写一个程序,询问用户要加多少个数字。然后,它会问他们这个数量的次数为一个数字,这将被添加到总数。然后打印出来。你知道吗</p>
<p>如果是这样的话,那么我相信您只需要向用户请求这个数量的数字,并以与您的类似的方式编写for循环:</p>
<pre><code>NumOfInt = int(input("How many numbers would you like to add up? : "))
total = 0
for i in range (NumOfInt):
newnum = int(input("Enter a number! : "))
total += newnum
print("Your total is: " + str(total))
</code></pre>
<p>这将把他们的输入加到总数中,直到他们输入的数字超过NumOfInt:</p>
<pre><code>How many numbers would you like to add up? : 4
Enter a number! : 1
Enter a number! : 2
Enter a number! : 3
Enter a number! : 4
Your total is: 10
</code></pre>
<p>我希望这有帮助:)</p>