for循环的语法格式:
for i in range(n):#从数据类型中拿一个值赋值给i
print(i)#打印i
例如:
#for
for i in range (1,6,2):#从一开始到六之前每隔上2个数字
print(i)#结果为1,3,5
# ------------------------------------------------
s = ["man", "woman", "girl", "boy", "sister"]
for i in s:#列表s中的每个元素给i
print(i)
#-------------------------------------------------
for i in range(5):
print(i)#结果为:0,1,2,3,4
for循环实例:数字0,1,2组成一个百位数,并且数字不重复!
#for
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
if (i != 0) and (i != j) and (i != k) and (j != k):
print (i,j,k)