variable = []

Now variable refers to an empty list*.

Of course this is an assignment, not a declaration. There's no way to say in Python "this variable should never refer to anything other than a list", since Python is dynamically typed.


*The default built-in Python type is called a list, not an array. It is an ordered container of arbitrary length that can hold a heterogenous collection of objects (their types do not matter and can be freely mixed). This should not be confused with the array module, which offers a type closer to the C array type; the contents must be homogenous (all of the same type), but the length is still dynamic.

Answer from sepp2k on Stack Overflow
Top answer
1 of 16
427
variable = []

Now variable refers to an empty list*.

Of course this is an assignment, not a declaration. There's no way to say in Python "this variable should never refer to anything other than a list", since Python is dynamically typed.


*The default built-in Python type is called a list, not an array. It is an ordered container of arbitrary length that can hold a heterogenous collection of objects (their types do not matter and can be freely mixed). This should not be confused with the array module, which offers a type closer to the C array type; the contents must be homogenous (all of the same type), but the length is still dynamic.

2 of 16
196

This is surprisingly complex topic in Python.

Practical answer

Arrays are represented by class list (see reference and do not mix them with generators).

Check out usage examples:

# empty array
arr = [] 

# init with values (can contain mixed types)
arr = [1, "eels"]

# get item by index (can be negative to access end of array)
arr = [1, 2, 3, 4, 5, 6]
arr[0]  # 1
arr[-1] # 6

# get length
length = len(arr)

# supports append and insert
arr.append(8)
arr.insert(6, 7)

Theoretical answer

Under the hood Python's list is a wrapper for a real array which contains references to items. Also, underlying array is created with some extra space.

Consequences of this are:

  • random access is really cheap (arr[6653] is same to arr[0])
  • append operation is 'for free' while some extra space
  • insert operation is expensive

Check this awesome table of operations complexity.

Also, please see this picture, where I've tried to show most important differences between array, array of references and linked list:

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ declaring-an-array-in-python
Declaring an Array in Python - GeeksforGeeks
July 10, 2025 - Explanation: [] creates a list (array-like) in Python. Elements are accessed using a[i] and modified with a[i] = value.
People also ask

How is an array different from a list in Python?
Arrays are different from Lists in Python in various aspects as Arrays generally store the elements of the same type of data while lists can store different types of data. Also, Arrays are very memory efficient and faster whereas lists offer more flexibility.
๐ŸŒ
intellipaat.com
intellipaat.com โ€บ home โ€บ blog โ€บ python arrays โ€“ the complete guide
What is Python Arrays amd How to Declare Them (UPDATED)
How do I initialize an array in Python with a size?
For a general one-dimensional sequence, use a list such as [None] * size or [0] * size. For a NumPy array, pass a length or shape tuple to a creation function such as np.zeros() or np.full().
๐ŸŒ
askpython.com
askpython.com โ€บ python โ€บ array โ€บ initialize-a-python-array
3 Ways to Initialize an Array in Python - AskPython
When should I use arrays instead of lists in Python?
You can use the Arrays when you want to store a larger dataset of the same type and prefer memory efficiency and speed. Lists are generally used for storing mixed data types.
๐ŸŒ
intellipaat.com
intellipaat.com โ€บ home โ€บ blog โ€บ python arrays โ€“ the complete guide
What is Python Arrays amd How to Declare Them (UPDATED)
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ python โ€บ declare an array in python
Declare and Initialize an Array (List) in Python | Sentry
October 1, 2026 - Create arrays in Python using list literals, the list() constructor, or the array module for type-restricted collections, with examples for each approach
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_arrays.asp
Python Arrays
Note: Python does not have built-in support for Arrays, but Python Lists can be used instead.
๐ŸŒ
AskPython
askpython.com โ€บ python โ€บ array โ€บ python-array-declaration
Python Array Declaration: A Comprehensive Guide for Beginners - AskPython
July 11, 2020 - In this method, we use the array() function from the array module to create an array in Python. In Python, you can declare arrays using the Python Array Module, Python List as an Array, or Python NumPy Array.
๐ŸŒ
Guru99
guru99.com โ€บ home โ€บ python โ€บ python array โ€“ define, create
Python Array โ€“ Define, Create
July 10, 2026 - Python arrays are much faster than list as it uses less memory. You can declare an array in Python while initializing it using the following syntax.
๐ŸŒ
AskPython
askpython.com โ€บ python โ€บ array โ€บ initialize-a-python-array
3 Ways to Initialize an Array in Python - AskPython
5 days ago - Use a Python list for general values, array.array for compact typed values, or NumPy when you need shaped numerical data.
Find elsewhere
๐ŸŒ
Altcademy
altcademy.com โ€บ blog โ€บ how-to-declare-an-array-in-python
How to declare an array in Python - Altcademy.com
September 9, 2023 - In Python, arrays are not used as frequently as lists. However, they still serve a purpose when dealing with large datasets. Declaring an array in Python is quite simple. We need to import the array module before we can create an array.
๐ŸŒ
The Knowledge Academy
theknowledgeacademy.com โ€บ blog โ€บ python-array
Python Arrays: Everything You Should Know
November 21, 2025 - So, letโ€™s explore two common ... you first need to import it into your code. Then, you can declare an Array by specifying the type of elements it will contain....
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ python-array-tutorial-define-index-methods
Python Array Tutorial โ€“ Define, Index, Methods
January 31, 2022 - Specifically, they are an ordered collection of elements with every value being of the same data type. That is the most important thing to remember about Python arrays - the fact that they can only hold a sequence of multiple items that are of the same type.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ array
Python Array of Numeric Values
March 26, 2024 - If that's the case, visit the Python list tutorial. To create an array of numeric values, we need to import the array module.
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ how-to-initialize-an-array-in-python
How to Initialize an Array in Python? (with Code) | FavTutor
January 27, 2021 - These elements allocate contiguous memory locations that allow easy modifications in data. In the python language, before using an array we need to declare a module named โ€œarrayโ€ using the keyword โ€œimportโ€.
๐ŸŒ
Codemia
codemia.io โ€บ home โ€บ knowledge hub โ€บ how do i declare an array in python?
How do I declare an array in Python? | Codemia
September 23, 2025 - For most everyday programming, the right answer is a list. If you need a compact typed container, use the standard library array module. If you need fast numeric computation, use NumPy arrays instead. Python does not require a special declaration syntax for lists.
๐ŸŒ
YouTube
youtube.com โ€บ finxter
How to declare an array in Python? - YouTube
Full Tutorial: https://blog.finxter.com/declare-an-array-python/Email Academy: https://blog.finxter.com/email-academy/โ–บโ–บ Do you want to thrive as a self-empl...
Published: February 22, 2022
Views: 1K
๐ŸŒ
YouTube
youtube.com โ€บ watch
Python Tutorial - 4 : How to declare Array in Python | Arrays in Python | Python Array | - YouTube
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
Published: August 28, 2023
๐ŸŒ
Hostman
hostman.com โ€บ tutorials โ€บ how-to-create-an-array-in-python
How to create an array in Python: A Step-by-Step Guide | Hostman
Therefore, to say that there are no arrays in Python is not entirely correct; they are still there, but you need to import a specific function to use them.
๐ŸŒ
Princeton University
introcs.cs.princeton.edu โ€บ python โ€บ 14array
Arrays in Python
To do so, put the array name after the in keyword in a for statement, as follows: Python has several built-in functions that can take arrays as arguments. We have already discussed the len() function.
๐ŸŒ
Intellipaat
intellipaat.com โ€บ home โ€บ blog โ€บ python arrays โ€“ the complete guide
What is Python Arrays amd How to Declare Them (UPDATED)
October 14, 2025 - In Python, arrays are generally used to store multiple values of the same type in a single variable. The array module in Python allows you to create and initialize an array and for that, you first need to import it first. Now, letโ€™s look at the example of declaring an array in Python.