range()函数
range(开始值,结束值,步长)
range(1,10) #1,2,3,4,5,6,7,8,9
range(1,10,2) #1,3,5,7,9
range(10,0,-1) #10,9,8,7,6,5,4,3,2,1
for in 循环语法
for 临时变量 in 集合(字符串、数组、range函数):
循环体
案例:
for 循环
str = "woaizhongguo"
for a in str :
print(a)
print("----分割线----")
for b in range(10,0,-1) : #for in 增强for 循环
print(b)