Using enumerate() for Index and Value in Python


Get both the index and the value when looping over a list.

Source Code

for index, value in enumerate(my_list):
    print(f"Index: {index}, Value: {value}")
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments