Python Forum

Full Version: How to stop an infinite loop in spyder if it's currently running?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm stunned I haven't been able to find anything online about stopping a program you've run.
The only thing I've been able to do so far is close spyder using a task manager and reopen it which is incredibly inefficient.
One site did say try ctrl+c which didn't work.
Post the code so we can help
my code:
print('Please think of a number between 0 and 100!')
guess=50
lowguess=0
highguess=100


while True:
    print('is your secret number ' + str(guess) + '?')
    x=input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. ")
    if x=='c':
        print('Game over. Your secret number was: ' +str(guess))
    if x=='h':
        guess+=-1
    if x=='l':
        guess+=1
    else:
        print("Sorry, I did not understand your input.")
I figured out how to fix the code by adding a break after line 11.

My primary question is how do I stop this code from running if I don't have a break on line 11? so far I've had to end it with a task manager and relaunch spyder.
Check here: https://github.com/spyder-ide/spyder/issues/1101

It looks like the focus has to be on the right window.