Python - Access Index in a For Loop

To access the current index in a for loop, simply wrap the the list (or dictionary, string and so on) that you are iterating over in Python's built-in enumerate() function, like this:

fruit = ['Apple', 'Banana', 'Orange']
for index, item in enumerate(fruit):
    print(index, item)

#0 Apple
#1 Banana
#2 Orange