Join our newsletter for the latest updates.

Python Program to Access Index of a List Using for Loop

In this example, you will learn to access the index of a list using a for loop.

To understand this example, you should have the knowledge of the following Python programming topics:


Example 1: Using enumerate

my_list = [21, 44, 35, 11]

for index, val in enumerate(my_list):
    print(index, val)

Output

0 21
1 44
2 35
3 11

Example 2: Start the indexing with non zero value

my_list = [21, 44, 35, 11]

for index, val in enumerate(my_list, start=1):
    print(index, val)

Output

1 21
2 44
3 35
4 11

The value of parameter start provides the starting index.