Answers for "use enumerate in python"

4

python for enumerate loop

>>> values = ["a","b","c"]
>>> for count, value in enumerate(values):
...     print(count, value)
...
0 a
1 b
2 c
Posted by: Guest on December-23-2020
24

enumerate python

for index,subj in enumerate(subjects):
    print(index,subj) ## enumerate will fetch the index
    
0 Statistics
1 Artificial intelligence
2 Biology
3 Commerce
4 Science
5 Maths
Posted by: Guest on April-25-2020
4

python enumerate for loop

presidents = ["Washington", "Adams", "Jefferson", "Madison", "Monroe", "Adams", "Jackson"]
for num, name in enumerate(presidents, start=1):
    print("President {}: {}".format(num, name))
Posted by: Guest on June-02-2020
0

what does enumerate do in python

The enumerate() function assigns an index to each item in an 
iterable object that can be used to reference the item later. 
What does enumerate do in Python? It makes it easier to keep 
track of the content of an iterable object.
Posted by: Guest on April-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language