loops(python3)

Sometimes, you need to perform code on each item in a list. This is called iteration, and it can be accomplished with a while loop and a counter variable.
For example:

words = [‘hello’, ‘words’, ‘viggies’, ‘eggs’]
counter = 0
max_index = len(words) – 1

while counter <= max_index:
word = words[counter]
print(word + ‘!’)
counter = counter+1

sololearn

原文链接:loops(python3)

© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享
If you hold tight, how can a free hand to hug now?
你若将过去抱的太紧,怎么能腾出手来拥抱现在?
评论 抢沙发

请登录后发表评论

    暂无评论内容