For loop iteration changing when I rerun the Python file

47 Views Asked by At
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

There are 1 best solutions below

4
Omace On BEST ANSWER

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.