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
how to use enumerate in python
rhymes=['check','make','rake']
for rhyme in enumerate(rhymes):
print(rhyme)
#prints out :
(0, 'check')
(1, 'make')
(2, 'rake')
#basically just prints out list elements with their index
for loop with enumerate python
presidents = ["Washington", "Adams", "Jefferson"]
for num, name in enumerate(presidents, start=0):
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