Python List: Creating a List

A Python list is one of the most common data structures you will use. This page shows the main ways to create a list, what list syntax looks like, and when each approach is useful.

Quick answer

numbers = [1, 2, 3]
names = ["Ana", "Ben", "Cara"]
empty_list = []
letters = list("abc")

print(numbers)
print(names)
print(empty_list)
print(letters)

Output:

[1, 2, 3]
['Ana', 'Ben', 'Cara']
[]
['a', 'b', 'c']

Use square brackets [] for most lists. Use list() when converting another iterable, such as a string, tuple, or range().

What this page covers

  • What a list is in Python
  • How to create a list with square brackets
  • How to create an empty list
  • How to create a list with the list() function
  • What kinds of values a list can store

What a Python list is

A list is an ordered collection of items.

This means:

  • A list can contain one item or many items
  • The order of items is kept
  • A list can hold different data types
  • A list is mutable, which means you can change it after creating it

Example:

items = ["apple", 10, True]

print(items)

Output:

['apple', 10, True]

If you want a broader introduction, see Python Lists Explained for Beginners or What is a List in Python?.

Create a list with square brackets

Use square brackets [] to create a list. Put items inside the brackets and separate them with commas.

This is the most common way to create a list.

numbers = [1, 2, 3]
names = ["Ana", "Ben", "Cara"]
mixed = [10, "hello", False]

print(numbers)
print(names)
print(mixed)

Output:

[1, 2, 3]
['Ana', 'Ben', 'Cara']
[10, 'hello', False]

Key points

  • Use [] to make a new list
  • Separate items with commas
  • Works with numbers, strings, booleans, and mixed values

Create an empty list

Use empty square brackets when you want a blank list.

my_list = []

print(my_list)
print(len(my_list))

Output:

[]
0

An empty list is useful when you want to build a list step by step.

names = []

names.append("Ana")
names.append("Ben")
names.append("Cara")

print(names)

Output:

['Ana', 'Ben', 'Cara']

To learn more about adding items, see the append() method.

Create a list with list()

Use list() to convert another iterable into a list.

Common inputs include:

  • strings
  • tuples
  • sets
  • range()

Example: convert a string

letters = list("abc")
print(letters)

Output:

['a', 'b', 'c']

Example: convert a tuple

numbers = list((1, 2, 3))
print(numbers)

Output:

[1, 2, 3]

Example: convert a range

values = list(range(5))
print(values)

Output:

[0, 1, 2, 3, 4]

list() is useful when you already have another iterable and want a list version of it. For more detail, see list(): Function Explained.

Lists can store many kinds of values

A list can store many types of data.

Examples include:

  • strings
  • integers
  • floats
  • booleans
  • other lists
data = ["Ana", 25, True, [1, 2, 3]]

print(data)

Output:

['Ana', 25, True, [1, 2, 3]]

The last item in this example is another list. This is called a nested list.

Python allows mixed types in one list, but beginners should usually keep list data consistent when possible. That makes code easier to read and work with.

Common beginner mistakes

Here are some common problems when creating lists.

Forgetting commas between items

This causes a syntax error.

# Wrong
numbers = [1 2 3]

Correct version:

numbers = [1, 2, 3]

Using () instead of []

Parentheses usually create a tuple, not a list.

my_values = (1, 2, 3)

print(type(my_values))

Output:

<class 'tuple'>

If you want a list, use square brackets:

my_values = [1, 2, 3]
print(type(my_values))

Expecting list("hello world") to create a list of words

list() splits a string into individual characters, not words.

result = list("hello world")
print(result)

Output:

['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']

If you want words, use split() instead:

words = "hello world".split()
print(words)

Output:

['hello', 'world']

Adding mismatched brackets or quotes

This causes syntax errors.

# Wrong
names = ["Ana", "Ben', "Cara"]

Make sure your quotes and brackets match correctly:

names = ["Ana", "Ben", "Cara"]

Common causes to check

If your list code is not working, check for these issues:

  • Using parentheses instead of square brackets
  • Leaving out commas between list items
  • Passing a non-iterable value to list()
  • Expecting list("abc") to return one string item instead of separate characters

Useful debugging checks

print(my_list)
print(type(my_list))
print(len(my_list))
print(list(range(5)))

These help you confirm:

  • what the list contains
  • whether the value is really a list
  • how many items it has
  • what list() does with range()

Use this page when you want to learn how to create a list.

Use related pages for the next step:

FAQ

How do I create an empty list in Python?

Use empty square brackets:

[]

What is the most common way to create a list?

Use square brackets with comma-separated items, such as:

[1, 2, 3]

What does list() do in Python?

It converts another iterable, such as a string, tuple, or range(), into a list.

Can a Python list store different data types?

Yes. A list can store mixed types like strings, numbers, and booleans.

What is the difference between [] and ()?

[] creates a list. () usually creates a tuple.

See also

Next step: learn how to add, access, and change list items using append(), indexing, and slicing.