[PYTHON] while else block

a = 0
b = 10
while a!=b:
	print("a!=b")
	a += 1
else:
	print("a==b")

In python, else may be attached to the while statement. The contents of the else block are executed when the condition judgment becomes false (when exiting the loop). However, when the break statement is exited, the condition judgment is not false, so the else block is not executed.

Recommended Posts

while else block
while else
while statement
[Introduction to Udemy Python3 + Application] 40.while else statement