Within a loop (such a while loop), the break statement unconditionally and immediately jumps out of the loop.
The continue statement jumps to the begin of the loop again.
x = 0
while True:
x += 1
if x == 2:
print('x = 2 -> continue')
continue
if x == 5:
print('x = 5 -> break')
break
print('end of loop, x = {0}'.format(x))
end of loop, x = 1
x = 2 -> continue
end of loop, x = 3
end of loop, x = 4
x = 5 -> break
Assignment in while statement
PEP-572 defines the assignment expression (aka walrus operator) with which it is (finally) possible to have an assignment in the while condition. The assignment expression requires at least Python version 3.8.
Each object can be evaluated in a boolean context, such as an if or while statement. The rules if an object is considered to be True or False are described here.