循环示例一:
count = 10 for i in range(10): print(i) else: print('nothing')
for循环示例二:
color = ['red','orange','yellow','green','cyan'] for i in range(len(color)): print(color[i])
for循环示例三:步长 2
for i in range(0,10,2): print(i)
for循环示例四:输出每个字母
for i in 'hello': print(i)
for循环示例五:遍历数组
color = ['color','orange','yellow','green'] for i in color: print(i)
简单求和示例:
sum = 0 for i in range(100): i+=1 sum += i print(sum)