英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论