Basically the list is implemented in the python virtual machine that runs the python code. It's written in C and here is the source code: https://github.com/python/cpython/blob/main/Objects/listobject.c If you are unfamiliar with C, that is basically like and ArrayList or a "dynamic array". It's a list that is a backed by an array. Array is a continuous memory segment that can be used to store stuff. There are really no directly accessible arrays in python by design. Arrays are fixed size, so the "dynamic array" refers to the fact that the insert/add/remove functions guarantee that the array is replaced with a new, longer array when it becomes full. Answer from 8dot30662386292pow2 on reddit.com
🌐
W3Schools
w3schools.com β€Ί python β€Ί python_lists_loop.asp
Python - Loop Lists
Learn more about for loops in our Python For Loops Chapter. You can also loop through the list items by referring to their index number.
🌐
Python documentation
docs.python.org β€Ί 3 β€Ί tutorial β€Ί datastructures.html
5. Data Structures β€” Python 3.14.6 documentation
We saw that lists and strings have many common properties, such as indexing and slicing operations. They are two examples of sequence data types (see Sequence Types β€” list, tuple, range). Since Python is an evolving language, other sequence data types may be added.
Discussions

How "list" is implemented in Python?
Basically the list is implemented in the python virtual machine that runs the python code. It's written in C and here is the source code: https://github.com/python/cpython/blob/main/Objects/listobject.c If you are unfamiliar with C, that is basically like and ArrayList or a "dynamic array". It's a list that is a backed by an array. Array is a continuous memory segment that can be used to store stuff. There are really no directly accessible arrays in python by design. Arrays are fixed size, so the "dynamic array" refers to the fact that the insert/add/remove functions guarantee that the array is replaced with a new, longer array when it becomes full. More on reddit.com
🌐 r/learnpython
25
45
August 26, 2024
python - Find a value in a list - Stack Overflow
I use the following to check if item is in my_list: if item in my_list: print("Desired item is in list") Is "if item in my_list:" the most "pythonic" way of findi... More on stackoverflow.com
🌐 stackoverflow.com
python - Fastest way to check if a value exists in a list - Stack Overflow
What is the fastest way to check if a value exists in a very large list (with millions of values) and what its index is? More on stackoverflow.com
🌐 stackoverflow.com
How to use Python 'in' operator to check my list/tuple contains each of the integers 0, 1, 2? - Stack Overflow
How do I use the Python in operator to check my list/tuple sltn contains each of the integers 0, 1, and 2? I tried the following, why are they both wrong: # Approach 1 if ("0","1","2") in sltn: ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com β€Ί python β€Ί python_lists.asp
Python Lists
Lists are one of 4 built-in data types in Python used to store collections of data, the other 3 are Tuple, Set, and Dictionary, all with different qualities and usage.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί python-lists
Python Lists - GeeksforGeeks
Python list stores references to objects, not the actual values directly. The list keeps memory addresses of objects like integers, strings or booleans.
Published Β  June 16, 2026
🌐
Google
developers.google.com β€Ί google for education β€Ί python β€Ί python lists
Python Lists | Python Education | Google for Developers
Python's built-in list type is defined using square brackets [ ] and elements are accessed using zero-based indexing.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί check-if-element-exists-in-list-in-python
Check if element exists in list in Python - GeeksforGeeks
Python provides an 'in' statement that checks if an element is present in an iterable or not. ... a = [10, 20, 30, 40, 50] if 30 in a: print("Element exists in the list") else: print("Element does not exist")
Published Β  November 13, 2025
Find elsewhere
🌐
Stanford CS
cs.stanford.edu β€Ί people β€Ί nick β€Ί py β€Ί python-list.html
Python Lists
The for-loop makes it easy to access each element in a list. In the for-loop, Python takes control of the variable after the word "for", setting that variable to point to each element in the list in turn, one at a time. In this example, the variable s points to 'a' on the first iteration of ...
🌐
Purple Frog Systems
purplefrogsystems.com β€Ί home β€Ί python lists – what do i need to know?
Python Lists – What do I need to know? - Purple Frog Systems
July 22, 2025 - In this post, we’ll cover everything you need to know about Python lists: what they are, how they work, and how to use them efficiently. What is a Python List? A list is a mutable, ordered, heterogeneous collection of items.
🌐
Reddit
reddit.com β€Ί r/learnpython β€Ί how "list" is implemented in python?
r/learnpython on Reddit: How "list" is implemented in Python?
August 26, 2024 -

Lately finding myself looking around in builtins.py file trying to learn/understand how the language works. Today I was reading about lists and how they work and etc. And as usually I end up in a class list in builtins.py file. I am now surprised that all the functions of list class is empty. For example, method append has 'pass' in it. And that is it.

Here is a code:

class list(object):
    
"""
    Built-in mutable sequence.
        If no argument is given, the constructor creates a new empty list.
    The argument must be an iterable if specified.
    """
    
def append(self, *args, **kwargs): # real signature unknown
        
""" Append object to the end of the list. """
        
pass
    def clear(self, *args, **kwargs): # real signature unknown
        
""" Remove all items from list. """
        
pass
    def copy(self, *args, **kwargs): # real signature unknown
        
""" Return a shallow copy of the list. """
        
pass

I wonder how this works? Why all methods are empty?

🌐
Codecademy
codecademy.com β€Ί learn β€Ί introduction-to-python-for-finance β€Ί modules β€Ί learn-python3-lists β€Ί cheatsheet
Introduction to Python: Lists Cheatsheet | Codecademy
In order to add one item, create a new list with a single value and then use the plus symbol to add the list. ... In Python, lists are a versatile data type that can contain multiple different data types within the same square brackets.
Top answer
1 of 14
1828

As for your first question: "if item is in my_list:" is perfectly fine and should work if item equals one of the elements inside my_list. The item must exactly match an item in the list. For instance, "abc" and "ABC" do not match. Floating point values in particular may suffer from inaccuracy. For instance, 1 - 1/3 != 2/3.

As for your second question: There's actually several possible ways if "finding" things in lists.

Checking if something is inside

This is the use case you describe: Checking whether something is inside a list or not. As you know, you can use the in operator for that:

3 in [1, 2, 3] # => True

Filtering a collection

That is, finding all elements in a sequence that meet a certain condition. You can use list comprehension or generator expressions for that:

matches = [x for x in lst if fulfills_some_condition(x)]
matches = (x for x in lst if x > 6)

The latter will return a generator which you can imagine as a sort of lazy list that will only be built as soon as you iterate through it. By the way, the first one is exactly equivalent to

matches = filter(fulfills_some_condition, lst)

in Python 2. Here you can see higher-order functions at work. In Python 3, filter doesn't return a list, but a generator-like object.

Finding the first occurrence

If you only want the first thing that matches a condition (but you don't know what it is yet), it's fine to use a for loop (possibly using the else clause as well, which is not really well-known). You can also use

next(x for x in lst if ...)

which will return the first match or raise a StopIteration if none is found. Alternatively, you can use

next((x for x in lst if ...), [default value])

Finding the location of an item

For lists, there's also the index method that can sometimes be useful if you want to know where a certain element is in the list:

[1,2,3].index(2) # => 1
[1,2,3].index(4) # => ValueError

However, note that if you have duplicates, .index always returns the lowest index:......

[1,2,3,2].index(2) # => 1

If there are duplicates and you want all the indexes then you can use enumerate() instead:

[i for i,x in enumerate([1,2,3,2]) if x==2] # => [1, 3]
2 of 14
281

If you want to find one element or None use default in next, it won't raise StopIteration if the item was not found in the list:

first_or_default = next((x for x in lst if ...), None)
🌐
Medium
medium.com β€Ί @sydasif78 β€Ί understanding-lists-in-python-cf33da320703
Understanding Lists in Python
October 25, 2023 - A list in Python is a fundamental data structure that allows you to store a collection of items. Lists are versatile and can hold various types of data, including strings, integers, Boolean, other lists, and more.
Top answer
1 of 12
2213
7 in a

Clearest and fastest way to do it.

You can also consider using a set, but constructing that set from your list may take more time than faster membership testing will save. The only way to be certain is to benchmark well. (this also depends on what operations you require)

2 of 12
381

As stated by others, in can be very slow for large lists. Here are some comparisons of the performances for in, set and bisect. Note the time (in second) is in log scale.

Code for testing:

import random
import bisect
import matplotlib.pyplot as plt
import math
import time


def method_in(a, b, c):
    start_time = time.time()
    for i, x in enumerate(a):
        if x in b:
            c[i] = 1
    return time.time() - start_time


def method_set_in(a, b, c):
    start_time = time.time()
    s = set(b)
    for i, x in enumerate(a):
        if x in s:
            c[i] = 1
    return time.time() - start_time


def method_bisect(a, b, c):
    start_time = time.time()
    b.sort()
    for i, x in enumerate(a):
        index = bisect.bisect_left(b, x)
        if index < len(a):
            if x == b[index]:
                c[i] = 1
    return time.time() - start_time


def profile():
    time_method_in = []
    time_method_set_in = []
    time_method_bisect = []

    # adjust range down if runtime is too long or up if there are too many zero entries in any of the time_method lists
    Nls = [x for x in range(10000, 30000, 1000)]
    for N in Nls:
        a = [x for x in range(0, N)]
        random.shuffle(a)
        b = [x for x in range(0, N)]
        random.shuffle(b)
        c = [0 for x in range(0, N)]

        time_method_in.append(method_in(a, b, c))
        time_method_set_in.append(method_set_in(a, b, c))
        time_method_bisect.append(method_bisect(a, b, c))

    plt.plot(Nls, time_method_in, marker='o', color='r', linestyle='-', label='in')
    plt.plot(Nls, time_method_set_in, marker='o', color='b', linestyle='-', label='set')
    plt.plot(Nls, time_method_bisect, marker='o', color='g', linestyle='-', label='bisect')
    plt.xlabel('list size', fontsize=18)
    plt.ylabel('log(time)', fontsize=18)
    plt.legend(loc='upper left')
    plt.yscale('log')
    plt.show()


profile()
🌐
Mimo
mimo.org β€Ί glossary β€Ί python β€Ί lists
Python List: Syntax and Examples [Python Tutorial]
Lists are mutable and can include elements of any type, including booleans, integers, strings, dictionaries, or other lists. A Python list is an ordered and changeable (mutable) collection that stores items inside square brackets [], separated by commas.
🌐
freeCodeCamp
freecodecamp.org β€Ί news β€Ί python-find-in-list-how-to-find-the-index-of-an-item-or-element-in-a-list
Python Find in List – How to Find the Index of an Item or Element in a List
February 24, 2022 - Each element inside a list will have a unique position that identifies it. That position is called the element's index. Indices in Python, and in all programming languages, start at 0 and not 1.
🌐
freeCodeCamp
freecodecamp.org β€Ί news β€Ί how-to-use-lists-in-python
How to Use Lists in Python – Explained with Example Code
March 1, 2024 - For example, let's say you're planning a trip to the grocery store. You can create a Python list called grocery_list to keep track of all the items you need to buy. Each item, such as "apples," "bananas," or "milk," is like an element in your list.
🌐
Programiz
programiz.com β€Ί python-programming β€Ί list
Python List (With Examples)
December 30, 2025 - We create a list by placing elements inside square brackets [], separated by commas. For example, # a list of three elements ages = [19, 26, 29] print(ages) ... Here, the ages list has three items.
🌐
Data Science Discovery
discovery.cs.illinois.edu β€Ί learn β€Ί Basics-of-Data-Science-with-Python β€Ί Lists-and-Functions-in-Python
Lists and Functions in Python - Data Science Discovery
A list is a built-in data structure in Python, meaning we do not need to import any libraries to use it, and is used to store a collection of items (in order).