List

suggest change

Introduction

The Python list is a general data structure widely used in Python programs. Other languages often call this kind of structure a dynamic array. Lists are mutable sequences, so they can be indexed and sliced. A list can contain different types of objects, including other lists.

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, 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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents