python for enumerate loop
>>> values = ["a","b","c"]
>>> for count, value in enumerate(values):
... print(count, value)
...
0 a
1 b
2 c
python for enumerate loop
>>> values = ["a","b","c"]
>>> for count, value in enumerate(values):
... print(count, value)
...
0 a
1 b
2 c
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
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))
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.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us