+ 5
Did you know else can be used after while loop in python?
7 Answers
+ 5
we can also use *else* :
> with a *for* loop
> with *try... except...*
+ 1
Yes! You can use it insted of using a flag.
+ 1
Yes. It will output anyway. When the while end
0
GERMAN Kashanskiy
I donât know what you mean with âanywayâ, but if you break the loop with âbreakâ or âreturnâ, what inside âelseâ will not run.
0
Per Bratthammar In his code else will be executed anyway. And this will happen after executing while
0
GERMAN Kashanskiy
I see. I understand what you mean now.
0
Manas Ranjan Adha
Hereâs an example using while loop with flag resp else:
https://code.sololearn.com/cvkH6fIponk2/?ref=app