News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

no datas

原力计划

posted on 2023-05-21 17:19     read(1060)     comment(0)     like(18)     collect(0)



If in the process of traversing the sequence, you need to access the index of the element, for example, to find the specified element through the index, the central idea is to traverse the index number, and find the corresponding element in the sequence through the index number of each loop.

Method 1: Traversing the elements of the sequence

Before the for loop starts, define an initial variable, the value of which is 0, the first index in the sequence starts from 0, and then loop through the sequence itself, after each loop, the initial traversal +1, the next loop At this time, you can find the element corresponding to the second index in the sequence, and print out the element corresponding to the index every time you loop.

mylist = ['jiangxl', 


Category of website: technical article > Blog

Author:python98k

link:http://www.pythonblackhole.com/blog/article/25271/96cb5d292f79d8f60d5e/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

18 0
collect article
collected

Comment content: (supports up to 255 characters)