Skip to main content

Python: Access List items

You can access the list items using following techniques:

1. Using index():

To access the element in any list one can refer to its  index number.


# Print element at index 3

Output: 4

2. Range of Indexes:

We can specify a range of indexes by specifying where to start and where to end the range. When specifying a range, the return value will be a new list with the specified items.


Output: [3,4]

3. Negative Indexing

Negative indexing means beginning from the end, -1 refers to the last item, -2 refers to the second last item etc.


Output: 5

Submitted by devanshi.srivastava on June 9, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.