while循环::
i = 0 number = [] while i < 6: print("Now the i is %d" % i) number.append(i) i = i + 1 print("nuber now:", number) print("haha,i now is %d" % i) print("the number:") for num in number: print(num)
Now the i is 0
nuber now: [0]
haha,i now is 1
Now the i is 1
nuber now: [0, 1]
haha,i now is 2
Now the i is 2
nuber now: [0, 1, 2]
haha,i now is 3
Now the i is 3
nuber now: [0, 1, 2, 3]
haha,i now is 4
Now the i is 4
nuber now: [0, 1, 2, 3, 4]
haha,i now is 5
Now the i is 5
nuber now: [0, 1, 2, 3, 4, 5]
haha,i now is 6
the number:
0
1
2
3
4
5