for循環:
a = [11,22,33,44]
for i in a:
print (i)
結果:
111🜎i=0
while i print (i)
i += 1
0
1
2
break與Continue:
i= 0
while i ==5時,退出所有循環
i += 1
i->: 0
i->: 1
i->: 2
i->: 3
i-> 4
i-> i->: 5
while x for x in range(0,10):
if x ==6:
if x ==6:
循環
print("x->:", x)
結果:
x->: 0
x->: 1
x->: 2
x->
x->: 1
x-> x->: 5
x->: 7 #缺x->: 6x->: 8
x->: 9
其他:
enumrate:
a = ["aa","bb ","cc","dd"]
print (i)
結果:
(5, 'aa' )
(6, 'bb')
(7, 'cc')
(8, 'dd')
1、
for n in range(1, 10):
)
結果:
1
2
4
56
7
8
9
for
結果:
0
4
12
16#以4作為step,依序列印