Index in Python Programming

Index in Python means the position of a specified item in a list or a string. This is done with the method called index (). This method shows the position of the item you put in the bracket from a range in a list or string.

Index in a list can go two ways or can be done in two ways:

1. Positive index: This is when the computer starts counting the position of the items in the list from 0, moving from left to right. 0, is the first position.

That means the list we created will be:

0  "Hey"
1  3

2  4.5

3  False

4  2.0

5  'Me'

6  True

Negative index: This is when you want the computer to count from right to left, and it ends at -1, being the last position when counting from the right.

-7  "Hey"
-6  3

-5  4.5

-4  False

-3  2.0

-2  'Me'

-1  True

We use the index for many operations in Python. The list we created can be indexed and used for many things.

Do you want to become an expert programmer? See books helping our students, interns, and beginners in software companies today (Click here)!

Leave a Comment

Python Tutorials