Python Function Reference

list

Create a list from the items of an iterable.

Python 3.13
list([iterable])
  • [ ]optional part
iterable
The items of the new list; without it, an empty list is created.
IterableOptional

Return value

A new list with the items in the same order.

Examples

List of string characters

Python 3.13
print(list('abc'))
['a', 'b', 'c']

List of dictionary keys

Python 3.13
print(list({'a': 1, 'b': 2}))
['a', 'b']

Details

list(a) creates a shallow copy: nested objects stay shared. A string gives a list of characters; to split a string into words, use str.split. A number cannot be iterated over, so list(5) raises TypeError.

See also

Where to learn