Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the index of the current iterator item in a loop? [duplicate]

Tags:

People also ask

How do you get the index of the current iteration of a foreach loop?

C# Program to Get the index of the Current Iteration of a foreach Loop Using Select() Method. The method Select() is a LINQ method. LINQ is a part of C# that is used to access different databases and data sources. The Select() method selects the value and index of the iteration of a foreach loop.

What is loop index in for-loop?

An index loop repeats for a number of times that is determined by a numeric value. An index loop is also known as a FOR loop.


How to obtain the index of the current item of a Python iterator in a loop?

For example when using regular expression finditer function which returns an iterator, how you can access the index of the iterator in a loop.

for item in re.finditer(pattern, text):     # How to obtain the index of the "item"