Try it here
Subscribe
enumerate function

Python enumerate function

python_enumerate_function

The enumerate() function is used to iterate through the sequence and retrieve the index position and it's corresponding value at the same time

The syntax of enumerate() is:

enumerate(iterable, start=0)
  • iterable - a sequence, an iterator, or objects that supports iteration
  • start (optional) - enumerate() starts counting from this number. If start is omitted, 0 is taken as start.
for i,v in enumerate(['Python','Java','C++']):
    print(i,v)  
0 Python  
1 Java  
2 C++

Writer profile pic

Aditya on Jun 07, 2020 at 09:04 am


This article is contributed by Aditya. If you like dEexams.com and would like to contribute, you can write your article here or mail your article to admin@deexams.com . See your article appearing on the dEexams.com main page and help others to learn.



Post Comment

Comments( 0)

×

Forgot Password

Please enter your email address below and we will send you information to change your password.