1.while循环
counter = 1while counter <=10 : counter +=1 print(counter)else: print('EOF')
2.for循环
# a = ['apple','orange','banana','grape']# for x in a:# print(x)a = [['apple','orange','banana','grape'],(1,2,3)]for x in a: for y in x: if y == 'orange': break print(y,end=' ') # print(y,end='\n')else: print('fruit is gone')# a = [1,2,3]# for x in a:# if x == 2:# break# # continue# print(x)# else:# print('EOF')
# for x in range(0,10):# print(x)# for x in range(0,10,2):# print(x,end=' | ')# for x in range(10,0,-2):# print(x,end=' | ')a = [1,2,3,4,5,6,7,8]# for i in range(0,len(a),2):# print(a[i],end=' | ')b = a[0:len(a):2]print(b)