🌐
Reddit
reddit.com › r/learnprogramming › curious how python list indexing works
r/learnprogramming on Reddit: Curious how Python list indexing works
May 18, 2023 -

Sorry if this question has an easy answer - I couldn't find one, but I might be using the wrong search terms.

From what I understand about arrays, the general process to index into an array is that there is a pointer that points to the base address of the array and consequently, the desired element can be retrieved by multiplying the element index by the size of the single element.

However, lists are data structures built into Python that also offer the same ability to index but also allow for different element types. So how does indexing work when the size of elements is not constant?

This also led me to believe that Python list are linked list, but searching that up revealed a couple of articles showing how to implement linked list into Python as they are not within the standard library:

https://www.geeksforgeeks.org/python-library-for-linked-list/

https://www.tutorialspoint.com/python_data_structure/python_linked_lists.htm

Top answer
1 of 3
4
From what I understand about arrays, the general process to index into an array is that there is a pointer that points to the base address of the array and consequently, the desired element can be retrieved by multiplying the element index by the size of the single element. That's how C works. However, lists are data structures built into Python that also offer the same ability to index but also allow for different element types. Here we're getting into internals of the interpreter, which can differ from one interpreter to another. The CPython interpreter is written in C, so it likely uses arrays of pointers, or arrays of some sort of struct with a pointer pointing to the actual data. Pointers are the same size regardless of what they're pointing to. Jython is an interpreter written in Java, so I would guess that uses a type that is a base class for an object instance.
2 of 3
3
It looks like CPython (the default implementation and the one you're probably using) uses dynamic arrays. https://github.com/python/cpython/blob/5c22476c01622f11b7745ee693f8b296a9d6a761/Include/listobject.h#L22 If you try to insert into an index in a list that does not yet exist, a new buffer will be allocated and all the existing values will be copied over. https://github.com/python/cpython/blob/1ca315538f2f9da6c7b86c4c46e76d454c1ec4b9/Objects/listobject.c#L290 And, as one of the other posters pointed out, these arrays are typically storing pointers for the values, which is how it deals with values of different types.
🌐
Railsware
railsware.com › home › engineering › indexing and slicing for lists, tuples, strings, other sequential types in python
Python Indexing and Slicing for Lists, Tuples, Strings, other Sequential Types | Railsware Blog
January 22, 2025 - As it was shown, indexing allows you to access/change/delete only a single cell of a list. What if we want to get a sublist of the list. Or we want to update a bunch of cells at once? Or we want to go on a frenzy and extend a list with an arbitrary number of new cells in any position? Those and lots of other cool tricks can be done with slice notation. Let’s look at this subject – feel free to follow along on your own editor or with an online Python compiler.
Discussions

Embarrassingly, i don't understand how list indexing works
Let us step back a little. Before understanding your example, try to grok the example below for i in range(0, 3): print(i) which results in: 0 1 2 And the example below my_list = [42, 6, 2024] for i in range(0, 3): print(i, my_list[i]) Which results in: 0 42 1 6 2 2024 Are those clear to ya? Thanks! More on reddit.com
🌐 r/learnpython
25
14
August 31, 2024
In Python, how do I index a list with another list? - Stack Overflow
A quick timing test (no pysco or ... the list comprehension 2.5x faster than the loop (1000 elements, repeated 10000 times). 2009-06-18T12:00:29.357Z+00:00 ... (using map and a lambda is even slower - to be expected, since it calls a function for each iteration) 2009-06-18T12:03:31.893Z+00:00 ... +1 If the indexing list is arbitrary, ... More on stackoverflow.com
🌐 stackoverflow.com
So confused about indexing
Or if you wonder why you would write 4 to get first four characters, line in "programming"[:4], it's because the stop index is not included in the slice. So to get slice of items #0 to 3, you specify 3 + 1, which is 4. More on reddit.com
🌐 r/learnpython
12
0
August 21, 2022
Indexing a np.array with another np.array
Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you. I think I have detected some formatting issues with your submission: Python code found in submission text that's not formatted as code. If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting. Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here . More on reddit.com
🌐 r/learnpython
4
1
July 14, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-list-slicing
Python List Slicing - GeeksforGeeks
a = [1, 2, 3, 4, 5, 6, 7, 8, 9] # Get elements starting from index -2 # to end of list b = a[-2:] print(b) # Get elements starting from index 0 # to index -3 (excluding 3th last index) c = a[:-3] print(c) # Get elements from index -4 # to -1 (excluding index -1) d = a[-4:-1] print(d) # Get every 2nd elements from index -8 # to -1 (excluding index -1) e = a[-8:-1:2] print(e) ... In this example, we'll reverse the entire list using a slicing trick. By using a negative step value, we can move through the list in reverse order. ... Explanation: The negative step (-1) indicates that Python should traverse the list in reverse order, starting from the end.
Published   July 23, 2025
🌐
W3Schools
w3schools.com › python › ref_list_index.asp
Python List index() Method
Remove List Duplicates Reverse ... Bootcamp Python Certificate Python Training ... The index() method returns the position at the first occurrence of the specified value....
🌐
Plain English
python.plainenglish.io › how-to-index-and-slice-python-lists-like-a-pro-66bfab709a81
How to Index and Slice Python Lists Like a Pro | Python in Plain English
July 15, 2025 - You’re not hungry for everything — you just want that third tray of spicy noodles (because obviously). Instead of lifting every lid, you count or read the labels from the start and go straight to what you want. That’s exactly how indexing in Python works.
🌐
Python documentation
docs.python.org › 3 › tutorial › datastructures.html
5. Data Structures — Python 3.14.3 documentation
Remove all items from the list. Similar to del a[:]. ... Return zero-based index of the first occurrence of x in the list.
🌐
Hyperskill
hyperskill.org › university › python › indexes-and-index-in-python
Indexes and index() in Python
July 17, 2024 - In Python, an index represents the position of an element within a list. It serves as an identifier to access specific elements in a list. The concept of Python index is useful in finding the location or position of a particular element within a list. Python provides the index() function, which ...
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › embarrassingly, i don't understand how list indexing works
r/learnpython on Reddit: Embarrassingly, i don't understand how list indexing works
August 31, 2024 -

I'm learning data structure and algorithms and i came across a question in the list section. i thought after i had understood python, i had understood list but a question was asked and i find myself finding it hard to understand how the list indexing works.

here's the sample code:

arr = [1, 2, 3, 4, 5, 6]

for i in range(1, 6):

arr[i - 1] = arr[i]

for i in range(0, 6):

print(arr[i], end = " ")

it looks simple to understand but, i just can't understand it.

🌐
Cisco
ipcisco.com › home › python list index
Python List Index | How to Access List Items? | Index Method ⋆ IpCisco
December 27, 2021 - This python method gives the first find member’s index. By the way, index values start with 0. It means that the index of the first item in a list is 0. The second item in a list has index 1, the third has 2 and so on.
🌐
Tutorialspoint
tutorialspoint.com › python › list_index.htm
Python List index() Method
The Python List index() method is used to retrieve the lowest index in a list at which a specified object appears. The object can be anything; a single element or a collection of elements in the form of another list, tuple, set etc.
🌐
GeeksforGeeks
geeksforgeeks.org › python › indexing-lists-of-lists-in-python
Indexing Lists Of Lists In Python - GeeksforGeeks
July 23, 2025 - Lists of lists, also known as nested lists or sometimes 2D lists, are powerful structures in Python for managing multi-dimensional data such as matrices or tables. Direct Indexing is the easiest way to access an element in a list of lists.
🌐
DataCamp
datacamp.com › tutorial › python-list-index
Python List index() Method Explained with Examples | DataCamp
March 28, 2025 - Python's built-in index() function is a useful tool for finding the index of a specific element in a sequence. This function takes an argument representing the value to search for and returns the index of the first occurrence of that value in the sequence. If the value is not found in the sequence, ...
🌐
Unstop
unstop.com › home › blog › python list index() method & use cases (with code examples)
Python List index() Method & Use Cases (With Code Examples)
February 3, 2025 - Python's list index() method is used to find the index position of elements in a list. Learn its syntax, components, uses, and real-world examples.
🌐
HackerEarth
hackerearth.com › practice › notes › samarthbhargav › a-quick-intro-to-indexing-in-python
A Quick intro to Indexing in Python - Samarth Bhargav
python lists are 0-indexed. So the first element is 0, second is 1, so on. So if the there are n elements in a list, the last element is n-1.
🌐
Codefinity
codefinity.com › courses › v2 › 102a5c09-d0fd-4d74-b116-a7f25cb8d9fe › 39cc7383-2374-4f3f-b322-2cb0109e6427 › df1b5ff1-bf08-4631-a38b-71e45b0101c0
Learn List Indexing in Python: Accessing Elements Efficiently | Mastering Python Lists
In Python, lists allow you to access individual elements using their index. Indexing starts at 0, meaning the first element in a list is at index 0, the second element is at index 1, and so on. This is called zero indexing.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-list-index
Python List index() - Find Index of Item - GeeksforGeeks
index() method in Python is a helpful tool when you want to find the position of a specific item in a list. It works by searching through the list from the beginning and returning the index (position) of the first occurrence of the element you're ...
Published   April 27, 2025
🌐
freeCodeCamp
freecodecamp.org › news › slicing-and-indexing-in-python
Slicing and Indexing in Python – Explained with Examples
December 11, 2025 - In Python, indexing starts from 0, which means the first element in a sequence is at position 0, the second element is at position 1, and so on. To access an element in a sequence, you can use square brackets [] with the index of the element ...
🌐
TUHH
www3.tuhh.de › sts › hoou › data-quality-explored › 0-5-3-lists.html
Lists and indexes — Data Quality Explored
Let us access the data ‘orange’ in the above nested list c. First, at index 0 there is a list [‘apple’,’orange’] and at index 1 there is another list [‘carrot’,’potato’]. Hence c[0] should give us the first list which contains ‘apple’ and ‘orange’. From this list we can take the second element (index 1) to get ‘orange’:
🌐
University of Pittsburgh
sites.pitt.edu › ~naraehan › python3 › mbb7.html
Python 3 Notes: Introduction to Lists, Indexing
Python 3 Notes [ HOME | LING 1330/2330 ] Tutorial 7: Introduction to Lists, Indexing << Previous Tutorial Next Tutorial >> On this page: list, list indexing with [], len(), string indexing with []. Video Tutorial Python 3 Changes NONE! Python 2 vs. 3 Summary · Video Summary Lists are created ...