Full name
list
Library
Built-in
Syntax
class list([iterable])
Description
The list function allows us to create a list of objects. The elements will be those included in the iterable passed as an argument, and will retain the same order as in this one. The iterable can be a sequence, a container that supports iteration, or an iterator object. If the iterable is already a list, an independent copy of it is returned.
The items in the list can be of different types.
Parameters
- iterable: (Optional) object whose elements will become part of the list.
Examples
In this example we create a list from another list, including elements of different types:
m = list(["a", "b", 1, 2, "c"])
print(m)