The half loop do-while

suggest change

Unlike other languages, Python doesn’t have a do-until or a do-while construct (this will allow code to be executed once before the condition is tested). However, you can combine a while True with a break to achieve the same purpose.

a = 10
while True:
    a = a-1
    print(a)
    if a<7:
        break
print('Done.')

This will print:

9
8
7
6
Done.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents