0
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 ?

0

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

4 Comments

But Shouldn't it Automatically stop running and rerun when I press "Run Python File". Also When I press ctrl + C it throws a traceback "KeyboardInterrupt".
When it throws back the keyboard interrupt does it show the line where the code got interrupted?
Yup. Here's the error: line 3, in <module> a = input("Enter a Number") KeyboardInterrupt
That means your program is definitely still running

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.