table of Contents
The for loop flow control
The for loop conditional statements
for i in range(3):
print(i)
# 0
# 1
# 2
for + break loop
- break ended for loop
lis = [1,2,3,4,5,6]
for i in lis:
if i == 4:
break
print(name)
# 1
# 2
# 3
for + contine loop
- contine for the end of this cycle, the next cycle into the
lis = [1,2,3]
for i in lis:
if i == 2:
contine
print(name)
# 1
# 3
nested for loop
- External for a loop, loop inside for all
for i in range(2):
for j in range(2):
print(i,j)
#0 0
#0 1
#1 0
#1 1