About 223,000 results
Open links in new tab
  1. python - How to emulate a do-while loop? - Stack Overflow

    While PEP 315 might seem related, that proposal is not for a do while loop as found in most other languages: looped statements both precede and follow the while statement.

  2. While loop with if/else statement in Python - Stack Overflow

    Apr 25, 2016 · So I am still in the process of learning Python and I am having difficultly with while loops. I have a sample of code below that includes while loop and if and else statements.

  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. Using or in a while loop (Python) - Stack Overflow

    Using or in a while loop (Python) Asked 11 years, 10 months ago Modified 7 years, 1 month ago Viewed 29k times

  5. 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 …

  6. Assign variable in while loop condition in Python?

    4 According to the FAQ from Python's documentation, iterating over the input with for construct or running an infinite while True loop and using break statement to terminate it, are preferred and …

  7. python - How to do while loops with multiple conditions - Stack …

    Can you clarify what you mean by "the code above does not work". What happens when you have the condition in the while statement?

  8. python - Why am I getting "IndentationError: expected an …

    In Python 3.10.9 I had an empty method followed by another method in a class definition. This resulted in error IndentationError: expected an indented block after function definition on line 10.

  9. 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 …

  10. python - Is the continue statement necessary in a while loop?

    That's because when python sees continue, it skips the rest of the while suite and starts over from the top. You won't see 'horse' or 'cow' either because when 'horse' is seen, we encounter the …