Enumerate () is a python built-in function.
1 Help (Enumerate)2Help onclassEnumerateinchModule Builtins:3 classenumerate (object)4Enumerate (iterable[, start]), iterator forIndex, value of Iterable5#enumerate (iterate variable [, start subscript]) returns the index and value of the iteration variable. (Note that dictionaries and collections can also be used, taking the position as an index)6Return an Enumerate object. Iterable must is another object that supports iteration. The enumerate object yields pairs containing a count ( fromStart, which defaults to zero) anda value yielded by the iterable argument.7Enumerate isUseful forObtaining an indexed list:8(0, Seq[0]), (1, seq[1]), (2, seq[2]), ...9 Ten Methods defined here: One A __getattribute__(Self, name,/) - Return getattr (self, name). - the __iter__(Self,/) - Implement iter (self). - - __new__(*args, **kwargs) fromBuiltins.type +Create and returnA new object. See Help (Type) foraccurate signature. - + __next__(Self,/) A Implement Next (self). at - __reduce__(...) -Return State information forPickling.
For an iterative iterable/of objects (such as lists, strings, tuples, dictionaries, and collections) that can be traversed.
Enumerate () is used to get a count in the for loop; enumerate () returns a enumerate object.
1 forIinchEnumerate ([1,2,3,4,5]):#Action on List2 Print(i)3 4(0, 1)5(1, 2)6(2, 3)7(3, 4)8(4, 5)9 Ten forIinchEnumerate ((+)):#effect on the tuple One Print(i) A -(0, 1) -(1, 2) the(2, 3) - - forIinchEnumerate (' Help'):#function on string - Print. IO + -(0,'h') +(1,'e') A(2,'L') at(3,'P') - - forIinchEnumerate ({'name':'Zoe',' Age': 18}):#effect on dictionaries - Print(i) - -(0,'name') in(1,' Age') - to forIinchEnumerate ({12,3}):#effect on the tuple + Print(i) - the(0, 3) *(1, 12)
Python built-in function enumerate ()