Introduction

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.

Syntax

Remarks

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](<http://stackoverflow.com/documentation/python/497/sets#t=201607211317316532895>), [tuple](<http://stackoverflow.com/documentation/python/927/tuples#t=201607211317041618066>), or [dictionary](<http://stackoverflow.com/documentation/python/396/dictionary#t=201607211316251118713>)

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.