AI Features

Lists

Learn about the details of the lists, along with a few of their useful properties in Python.

Overview

Python’s generic list structure is integrated into a number of language features. We don’t need to import them and rarely need to use method syntax to access their features. We can visit all the items in a list without explicitly requesting an iterator object, and we can construct a list (as with a dictionary) with very simple-looking syntax.

In Python, lists should normally be used when we want to store several instances of the same type of object; lists of strings or lists of numbers. We’ll often use a type hint list[T] to specify the type, T, of an object kept in the list, for example, list[int] or list[str].

Note: Remember that from __future__ import annotations is ...