About 690,000 results
Open links in new tab
  1. python - How to remove items from a list while iterating ... - Stack ...

    Oct 23, 2012 · I'm iterating over a list of tuples in Python, and am attempting to remove them if they meet certain criteria. for tup in somelist: if determine(tup): code_to_remove_tup What …

  2. When to use "while" or "for" in Python - Stack Overflow

    May 28, 2009 · When I should use a while loop or a for loop in Python? It looks like people prefer using a for loop (for brevity?). Is there any specific situation which I should use one or the …

  3. Else clause on Python while statement - Stack Overflow

    Jul 21, 2010 · The better use of 'while: else:' construction in Python should be if no loop is executed in 'while' then the 'else' statement is executed. The way it works today doesn't make …

  4. What does "while True" mean in Python? - Stack Overflow

    Feb 13, 2020 · The while True: form is common in Python for indefinite loops with some way of breaking out of the loop. Learn Python flow control to understand how you break out of while …

  5. python - Using tqdm progress bar in a while loop - Stack Overflow

    Aug 22, 2017 · 49 Because of the attention, this post is attracting I thought it would be good to point out how this can be achieved with an infinite while loop as well. To use an infinite loop …

  6. Python : How does `while` loop work in python when reading lines?

    Jun 16, 2016 · How does while loop work in python when reading lines? state=True #can be set to {anyInterger,True,False} while state: #do a task #if task done change state to exit loop so …

  7. python - How to make program go back to the top of the code …

    2 Python has control flow statements instead of goto statements. One implementation of control flow is Python's while loop. You can give it a boolean condition (boolean values are either True …

  8. Python loop to run for certain amount of seconds

    import time t_end = time.time() + 60 * 15 while time.time() < t_end: # do whatever you do This will run for 15 min x 60 s = 900 seconds. Function time.time returns the current time in seconds …

  9. loops - Is there a "do ... until" in Python? - Stack Overflow

    Jun 21, 2015 · A do-while (although it should be called until) is my greatest wish for Python.

  10. How do I plot in real-time in a while loop? - Stack Overflow

    42 None of the methods worked for me. But I have found this Real time matplotlib plot is not working while still in a loop All you need is to add