#!# =======
#!#  Loops
#!# =======
#!#
#!# This page contains a memo on loop statements.

#!#
#!# For Loop
#!# --------

for i in range(5):
    print(i)
else:
    print('end')
#o#

for i in range(1000):
    if 5 < i:
        break
    print(i)
else:
    print('end')
#o#

for i in range(100):
    if not (10 < i < 16):
        continue
    print(i)
else:
    print('end')
#o#


#!#
#!# While Loop
#!# ----------

i = 0
while i < 5:
    print(i)
    i += 1
else:
    print('end')
#o#

i = 0
while i < 1000:
    if 5 < i:
        break
    print(i)
    i += 1
else:
    print('end')
#o#

3.3.12. Loops

This page contains a memo on loop statements.

3.3.12.1. For Loop

for i in range(5):
    print(i)
else:
    print('end')
0
1
2
3
4
end
for i in range(1000):
    if 5 < i:
        break
    print(i)
else:
    print('end')
0
1
2
3
4
5
for i in range(100):
    if not (10 < i < 16):
        continue
    print(i)
else:
    print('end')
11
12
13
14
15
end

3.3.12.2. While Loop

i = 0
while i < 5:
    print(i)
    i += 1
else:
    print('end')
0
1
2
3
4
end
i = 0
while i < 1000:
    if 5 < i:
        break
    print(i)
    i += 1
else:
    print('end')
0
1
2
3
4
5