About 50 results
Open links in new tab
  1. python - How can I stop a While loop? - Stack Overflow

    I wrote a while loop in a function, but don't know how to stop it. When it doesn't meet its final condition, the loop just go for ever. How can I stop it?

  2. Exit while loop in Python - Stack Overflow

    May 21, 2013 · In the code below, I'd like the while loop to exit as soon as a + b + c = 1000. However, testing with print statements shows that it just continues until the for loops are done. I've tried while Tr...

  3. How to break out of while loop in Python? - Stack Overflow

    Jan 30, 2013 · The condition that causes a while loop to stop iterating should always be clear from the while loop line of code itself without having to look elsewhere. Phil has the "correct" solution, as it …

  4. python - Ending an infinite while loop - Stack Overflow

    Sep 25, 2013 · I currently have code that basically runs an infinite while loop to collect data from users. Constantly updating dictionaries/lists based on the contents of a text file. For reference: while (True...

  5. How to end a while loop in another Thread? - Stack Overflow

    Sep 8, 2021 · Here's how to fix those things and be able to stop the while loop in the other thread. Instead of a simple boolean variable, it uses an Threading.Event object to control the loop and allow …

  6. python - How to stop one or multiple for loop (s) - Stack Overflow

    for b in range(..): if some condition: # break the inner loop break else: # will be called if the previous loop did not end with a `break` continue # but here we end up right after breaking the inner loop, so we …

  7. How to stop an infinite loop safely in Python? - Stack Overflow

    Oct 3, 2015 · It is the infinitive python loop in a separate thread with the safe signal ending. Also has thread-blocking sleep step - up to you to keep it, replace for asyncio implementation or remove. This …

  8. How to kill a while loop with a keystroke? - Stack Overflow

    Nov 1, 2012 · I am reading serial data and writing to a csv file using a while loop. I want the user to be able to kill the while loop once they feel they have collected enough data. while True: #do a bunch...

  9. Exit while loop by user hitting ENTER key - Stack Overflow

    I am a python newbie and have been asked to carry out an exercise: make a program loop until exit is requested by the user hitting <Return> only. So far I have: User = raw_input ('Enter <Ca...

  10. python - When Does a While Loop Break - Stack Overflow

    Jan 9, 2013 · A while loop doesn't automatically exit in mid-loop as soon as its condition is no longer true; it just checks the condition at the start of each loop. If you want to get out early, you need to …