Difference between List and Array in Python (original) (raw)

Last Updated : 14 Jan, 2026

Python provides multiple data structures for storing collections of values, among which Lists and Arrays are two commonly used options. While both support indexing, iteration and storage of multiple elements, they differ significantly in terms of memory usage, data type flexibility and performance.

Lists

A list is a built-in Python data structure used to store an ordered collection of elements that can belong to different data types. Lists are dynamic, meaning their size can change during execution.

**Example:

In this example, we are creating a list in Python. The first element of the list is an integer, the second is a Python string and the third is a list of characters.

Python `

sample_list = [1, "Yash", ['a', 'e']] print(type(sample_list)) print(sample_list)

`

**Output:

<class 'list'>
[1, 'Yash', ['a', 'e']]

Arrays

An array is a data structure that stores elements of the same data type in contiguous memory locations, making it efficient for numerical operations. Arrays require the array module to be used.

**Example:

In this example, we will create a Python array by using the array() function of the array module and see its type using the type() function.

Python `

import array as arr a = arr.array('i', [1, 2, 3]) print(type(a)) for i in a: print(i, end=" ")

`

**Output:

<class 'array.array'>
1 2 3

Difference Between List and Array in Python

The following table shows the differences between List and Array in Python:

Basis List Array
Data Type Handling Can store mixed data types Stores only one data type
Memory Usage Uses more memory due to flexible storage Uses less memory because of uniform data type
Performance Slower for numerical operations Faster for numeric computations
Flexibility Supports easy insertion, deletion and resizing Less flexible due to fixed type and size constraints
Arithmetic Operations Cannot perform element-wise arithmetic directly Supports element-wise arithmetic
Built-in Support Available by default in Python Requires importing the array module
Best Use Case General-purpose and mixed-type data Numeric and scientific data processing
Data Consistency Allows mixed values without restriction Enforces strict type consistency