do while
- do while
There is no do-while in Python, but you can emulate it:
while True:
do_stuff()
if not loop_condition():
break
x = 0
while True:
x += 1
print(x)
if x > 0:
break
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
There is no do-while in Python, but you can emulate it:
while True:
do_stuff()
if not loop_condition():
break
x = 0
while True:
x += 1
print(x)
if x > 0:
break