Python list() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Built-in type

Definition

In Python, list(iterable) creates a new list containing every item of the iterable, in order: list("abc") is ['a', 'b', 'c']. list() with no argument returns an empty list, the same as [].

It is the usual way to turn lazy objects such as range, map, or zip into a real list you can index and print. Passing an existing list makes a shallow copy: a new outer list that still shares the inner objects.

list is a built-in type (a class) that you call like a function: each call creates a new list object. Like every built-in, it lives in the builtins module and is always available without an import.

Syntax

Pass any iterable; you always get a fresh list.

python
items = list(iterable)
empty = list()
CallWhat it does
list("abc")Returns ['a', 'b', 'c'].
list(range(3))Returns [0, 1, 2].
list(d)Returns the dict's keys in insertion order.
list(old)A shallow copy of another list.

list(x) always creates a new object, even when x is already a list.

Library declarations
python
list(iterable=(), /)
# class list: a mutable built-in type

Parameters

ParameterDescription
iterableOptional. Any iterable: string, list, tuple, set, dict, range, generator, file, ... Default: empty.

Return Value

Return ValueDescription
listA new list with the iterable's items.

Python Examples

Example 1 — Build Lists from Different Iterables

Convert a string, a range, a tuple, and a dict into lists.

python
print(list("abc"))
print(list(range(5)))
print(list((1, 2, 3)))
print(list({"x": 1, "y": 2}))
print(list())

How It Works

  1. Strings split into characters. Iterating a string yields one character at a time.
  2. Ranges expand. list(range(5)) materializes the numbers 0 to 4.
  3. Dicts give keys. Iterating a dict yields its keys, in the order they were inserted.
  4. No argument. list() is an empty list.

Example 2 — list() Makes a Shallow Copy

Copy a list that contains another list and change both levels.

python
original = [1, 2, [3, 4]]
copy = list(original)

copy.append(5)
copy[2].append(99)

print("original:", original)
print("copy:    ", copy)
print(copy is original, copy[2] is original[2])

How It Works

  1. New outer list. append(5) on the copy does not touch original.
  2. Shared inner list. copy[2] and original[2] are the same list object, so 99 shows up in both.
  3. Identity check. copy is original is False, but the nested items are identical objects.
  4. Deep copies. Use copy.deepcopy(original) when nested data must be independent.

Example 3 — Turn Iterators and dict.items() into Lists

See that an iterator can be consumed only once, and build lists of pairs and rows.

python
squares = map(lambda n: n * n, [1, 2, 3])
print(list(squares))
print(list(squares))

prices = {"tea": 3, "cake": 5}
pairs = list(prices.items())
print(pairs)
print(pairs[0])

matrix = [list(row) for row in ["ab", "cd"]]
print(matrix)

How It Works

  1. Lazy until listed. map() computes nothing until list() pulls the values out.
  2. One pass only. The second list(squares) is empty because the iterator is already exhausted.
  3. Indexable pairs. list(prices.items()) gives tuples you can index, unlike the items view itself.
  4. Lists of lists. Calling list() on each string builds a small character grid.

Frequently Asked Questions

It creates a new list from an iterable, such as list("abc") or list(range(5)). With no argument it returns [].
No. list("ab") gives ['a', 'b'], while ["ab"] is a one-item list. list(5) fails because an int is not iterable.
Yes, it makes a shallow copy. Nested objects are shared; use copy.deepcopy() for a full copy.
list(d) gives the keys, list(d.values()) the values, and list(d.items()) the key/value pairs.
Iterators can be read only once. Store the first list() result, or recreate the iterator.

Next: locals()

Get a dictionary of the current local variables.

locals() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful