## 定义list数组
lstrs = [‘t1‘,‘t2‘,‘t3‘,‘t4‘]
print(‘lstrs is‘,lstrs)
i = 0
## test for loop
for lstr in lstrs:
print(‘lstrs[%d] is‘ % i,lstr )
i = i + 1
print(‘end for loop‘)
j = 0
## test while loop
while j <= 3:
print(‘lstrs[%d] is‘ % j,lstrs[j] )
j = j + 1
print(‘end while loop‘)
k = 0
## test break and continue
print(‘k=0 , k<=10 ,1 continue, k>=4 break‘)
while k <= 10:
if k == 1:
k = k + 1
continue
print(‘k is %d‘ % k)
if k >= 4:
break
k = k + 1
print(‘end test for break and continue‘)
时间: 2024-10-22 15:47:34