For loop iteration changing when I rerun the Python file

huangapple go评论59阅读模式
英文:

For loop iteration changing when I rerun the Python file

问题

对于范围在1到5之间的i:
    打印i
    a = 输入("输入一个数字")
如果我没有输入任何内容并在VSCODE终端中重新运行文件,for循环会继续前进。
然而,我本来期望它重新设置为初始值1。
为什么会这样,我该如何修复?
英文:
for i in range(1,5):
    print(i)
    a = input("Enter a Number")

If I don't Enter anything into the Input and Rerun the File again In VSCODE Terminal, The For loop iteration is advancing.

However I was expecting it to reset back to its initial value of 1.
Why is this happening and How do I fix It ?

答案1

得分: 0

可能是你仍然无意中运行了程序。尝试点击右上角的播放按钮,然后从下拉菜单中选择“运行Python文件”。如果你想使用终端,请按下Ctrl + C确保程序停止运行,然后从终端运行你的程序。

英文:

It might be that you're still running the program on accident. Try clicking the play button in the top right corner and selecting "Run Python File" from the drop down menu. If you want to use the terminal, press ctrl + C to ensure the program stops running, then run your program from the terminal.

huangapple
  • 本文由 发表于 2023年6月19日 04:50:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76502486.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定