Using enumerate() for Index-Value Pairs in Loops in Python


Retrieve index and value simultaneously while looping through a list.

Source Code

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