Python进阶之for循环

时间:2021-05-02 22:13:46   收藏:0   阅读:32
# Work hard and try agin. Done is better than perfect.

# 进行for 循环的学习
for i in range(1,4):
print(‘i=‘,i) # 步长默认1,取1不取4
print(‘------------‘)
s=0
for i in range(1,5,2):
s = s+1
print(‘i=‘,i) # 步上默认2,取1不取5
print(‘s=‘,s)
print(‘------------‘)
for i in range(5,1,-1):
print("i=",i) # 取5不取1
执行结果:

技术分享图片

原文:https://www.cnblogs.com/zx1313/p/14726048.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!