Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Loop Through An Array In Python With An Index

Code

items = ["a", "b", "c", "d", "e"]

for index, item in enumerate(items):
        print(index, item)

Results

0 a
1 b
2 c
3 d
4 e