Python Language List


The Python List is a general data structure widely used in Python programs. They are found in other languages, often referred to as dynamic arrays. They are both mutable and a sequence data type that allows them to be indexed and sliced. The list can contain different types of objects, including other list objects.


  • [value, value, ...]
  • list([iterable])


list is a particular type of iterable, but it is not the only one that exists in Python. Sometimes it will be better to use set, tuple, or dictionary

list is the name given in Python to dynamic arrays (similar to vector<void*> from C++ or Java's ArrayList<Object>). It is not a linked-list.

Accessing elements is done in constant time and is very fast. Appending elements to the end of the list is amortized constant time, but once in a while it might involve allocation and copying of the whole list.

List comprehensions are related to lists.