About 54 results
Open links in new tab
  1. 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 sense because …

  2. Why does python use 'else' after for and while loops?

    Feb 13, 2016 · Almost 10 years after this question has been asked and after programming with Python for 3 years, this is the first time I've seen the "for-else", "while-else" construct. I hope its low …

  3. ¿Else en un bucle While? - Python - Stack Overflow en español

    Oct 26, 2019 · Tengo una duda... en un bucle while en python. ¿Porqué en un bucle while cuando es infinito el "Else" no rompe el bucle y es necesario usar un break, pero cuando el bucle es finito, el …

  4. 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.

  5. python - Bucle While con if y else para ambos - Stack Overflow en …

    Aug 24, 2020 · estoy empezando en python, y aunque algunas cosas las tengo claras, con otras que creo que son fáciles me quedo estancado. En este caso tengo un bucle while con un if dentro, el …

  6. python - While loop with if/elif/else statement - Stack Overflow

    Jun 10, 2018 · If the user does not input either 'y' or 'n' it should keep looping, but is does not Because you have the break after the if-elif-else. So it will break in any case. Move that break inside the if …

  7. What is the benefit(s) of having 'else clause' for the while loop in ...

    Dec 26, 2010 · The else suite on Python loops is best thought of for the case where the loop is performing a search. It's where you handle the case where your search was unsuccessful.

  8. How to write a "while-else" condition in one line in Python?

    How to write a "while-else" condition in one line in Python? Ask Question Asked 8 years ago Modified 8 years ago

  9. Como usar while e if no Python? - Stack Overflow em Português

    Apr 18, 2021 · Me perdoem se é uma pergunta idiota, mas sou iniciante. Tenho que usar a condição while para finalizar o programa. No caso, o código tem que rodar enquanto o peso for diferente de 0. …

  10. How can I make sense of the `else` clause of Python loops?

    Jun 5, 2016 · In normal execution, the while loop repeatedly runs until the condition evaluates to false, and therefore naturally exiting the loop runs the else clause. When you execute a break statement, …