range(n) 从n 开始 到 n-1 结束
for i in range(10):
print(i) #0-9
range(n,m)从n 开始 到 m -1 结束
for i in range(1,10):
print(i) #1-9
range(1,10,3) 1+3 4+3
for i in range(1,10,3):
print(i) # 1,4,7
获取列表的索引, 拿到索引, 拿到相应的元素
lst = ['qiaoning','wangtao','lixianglong','shell','python']
for i in range(len(lst)):
print(i)
print(lst[i])
网友评论