If you’ve tried [[0] * 3] * 2 for a grid, you’ve probably watched one update land in every row. The normal way to create a list in Python is simpler: put comma-separated values inside square brackets, like prices = [4.75, 4.25, 5.50].
That bug happens because * copies one inner list instead of building new rows. You’ll see the fix in Method 5; I ran each snippet on Python 3.12.5.
In this tutorial, I’ll show you seven ways to create a list in Python, from plain brackets to lists of lists, with a table at the end to help you pick one.
The sample coffee menu list we’ll use
Every example uses the same sample list: an Austin coffee shop’s five drinks and their prices in US dollars.
items: five drink namesprices: 4.75, 4.25, 5.50, 2.95 and 4.95 (the 5.50 matters later)- Austin sales tax: 8.25%
Need bigger test data? You can generate a list of random numbers in Python instead.
Method 1: Create a list with square brackets (Recommended)
Use square brackets when you already know the values. It’s the shortest and most readable option.
Here’s the code with the same menu items and prices:
items = ["Latte", "Cold Brew", "Mocha", "Drip Coffee", "Chai Latte"]
prices = [4.75, 4.25, 5.50, 2.95, 4.95]
order = ["Latte", 2, 4.75, True] # types can mix
print(items)
print(prices)
print(order)
print(type(items), len(items))
print(items[0], "|", items[-1], "|", prices[1:3])
Output:
['Latte', 'Cold Brew', 'Mocha', 'Drip Coffee', 'Chai Latte']
[4.75, 4.25, 5.5, 2.95, 4.95]
['Latte', 2, 4.75, True]
<class 'list'> 5
Latte | Chai Latte | [4.25, 5.5]
Python prints both lists, the mixed order list, a length of 5 and the slice [4.25, 5.5].

How does this code work?
Brackets make a new list, and commas separate the items. Order is kept, so items[0] is the Latte and items[-1] counts from the end.
Important: 5.50 prints as 5.5 because floats drop trailing zeros, so use f"{p:.2f}" for money. An index past the end raises an error; see fixing IndexError: list index out of range.
Method 2: Create a list from other data with list()
Use the list() constructor when the values already live in another iterable, like a range, string, dictionary or set.
print(list()) # empty list
print(list(range(1, 6))) # 1 through 5
print(list("TX-78701")) # one item per character
menu = {"Latte": 4.75, "Mocha": 5.50, "Chai Latte": 4.95}
print(list(menu)) # dict -> its keys
print(sorted({"Mocha", "Latte", "Chai Latte"})) # set -> sorted list
Output:
[]
[1, 2, 3, 4, 5]
['T', 'X', '-', '7', '8', '7', '0', '1']
['Latte', 'Mocha', 'Chai Latte']
['Chai Latte', 'Latte', 'Mocha']
You get an empty list, the numbers 1 through 5, eight characters from the ZIP string, and the menu’s three keys.
How does this code work?
list() copies each item of whatever you pass into a new list. A dictionary gives its keys unless you call .values().
Sets have no order, so I wrapped that one in sorted(). For the trade-offs, see list vs set in Python.
Method 3: Start with an empty list and append() in a loop
Use an empty list when items arrive one at a time. Here I add 8.25% sales tax to the same five prices:
prices = [4.75, 4.25, 5.50, 2.95, 4.95]
TAX = 0.0825 # Austin, TX sales tax
with_tax = [] # start empty
for price in prices:
with_tax.append(round(price * (1 + TAX), 2))
print(with_tax)
print(f"One of each drink: ${sum(with_tax):.2f}")
Output:
[5.14, 4.6, 5.95, 3.19, 5.36]
One of each drink: $24.24
The loop builds [5.14, 4.6, 5.95, 3.19, 5.36], and one of each drink costs $24.24 with tax.

How does this code work?
with_tax = [] creates an empty list, and each pass of the loop appends one taxed price to the end. More on empty lists is in how to create an empty list in Python.
append() adds one item. To add several at once, use extend() or +=, as shown in appending multiple items to a list in Python.
Method 4: Build a list in one line with a list comprehension
A list comprehension does the Method 3 loop in one line, with an optional filter.
items = ["Latte", "Cold Brew", "Mocha", "Drip Coffee", "Chai Latte"]
prices = [4.75, 4.25, 5.50, 2.95, 4.95]
with_tax = [round(p * 1.0825, 2) for p in prices]
under_5 = [name for name, p in zip(items, prices) if p < 5]
print(with_tax)
print(under_5)
Output:
[5.14, 4.6, 5.95, 3.19, 5.36]
['Latte', 'Cold Brew', 'Drip Coffee', 'Chai Latte']
The first line matches the loop result, and the filter keeps the four drinks under $5.00.

How does this code work?
Read [round(p * 1.0825, 2) for p in prices] as “for each p in prices, keep this value”. The if p < 5 part drops the Mocha, the only drink at $5.50.
zip() pairs names with prices. For the full syntax, see list comprehension in Python, and for conditions, list comprehensions with if-else.
Method 5: Create a list of repeated values with *
The * operator repeats a list, which is handy for counters. It also causes the grid bug from the intro, so here’s the trap and the fix:
cups_sold = [0] * 5 # one counter per drink
print(cups_sold)
bad_grid = [[0] * 3] * 2 # 2 stores x 3 days
bad_grid[0][0] = 18
print("bad: ", bad_grid)
grid = [[0] * 3 for _ in range(2)] # a new row every time
grid[0][0] = 18
print("good:", grid)
print(bad_grid[0] is bad_grid[1], grid[0] is grid[1])
Output:
[0, 0, 0, 0, 0]
bad: [[18, 0, 0], [18, 0, 0]]
good: [[18, 0, 0], [0, 0, 0]]
True False
[0] * 5 gives five zeros. Setting one cell in bad_grid changes both rows to [18, 0, 0], while the comprehension grid changes only the first row.

How does this code work?
[0] * 5 is safe because ints can’t change in place. [[0] * 3] * 2 repeats one inner list, so bad_grid[0] is bad_grid[1] prints True.
The comprehension runs [0] * 3 once per row, so each row is a new list. Sizing tricks like [None] * n are covered in initializing a list of size N in Python.
Method 6: Create a list from a string or user input
Text is a common source of lists, and split() does most of the work.
csv_line = "Latte,Cold Brew,Mocha"
names = csv_line.split(",")
print(names)
seasonal = ["Pumpkin Spice Latte", "Peppermint Mocha"]
full_menu = [*names, *seasonal] # unpack both into one new list
print(len(full_menu), full_menu[-1])
Output:
['Latte', 'Cold Brew', 'Mocha']
5 Peppermint Mocha
The CSV line becomes three names, and unpacking joins them with two seasonal drinks into a five-item list.
For typed values, combine input() with split(). I entered the same five prices:
raw = input("Enter today's prices: ")
prices = [float(x) for x in raw.split()]
print(prices)
print(f"Average price: ${sum(prices) / len(prices):.2f}")
Output:
Enter today's prices: 4.75 4.25 5.50 2.95 4.95
[4.75, 4.25, 5.5, 2.95, 4.95]
Average price: $4.48
How does this code work?
split(",") cuts at commas; split() cuts at whitespace. Both return strings, so float() converts them.
[*names, *seasonal] unpacks both lists into one new list. When the text comes from a file, see reading a file into a list in Python.
Method 7: Create a nested list (list of lists)
Use a nested list for table-like data, one inner list per row. Here are weekday cups sold at three Texas stores:
stores = ["Austin", "Dallas", "Houston"]
sales = [ # cups sold, Monday to Friday
[120, 135, 128, 142, 160], # Austin
[98, 101, 110, 105, 131], # Dallas
[87, 92, 95, 99, 118], # Houston
]
print(sales[1][4]) # Dallas, Friday
for store, row in zip(stores, sales):
print(f"{store:<8} {sum(row):>4} cups")
fridays = [row[4] for row in sales]
print(fridays)
Output:
131
Austin 685 cups
Dallas 545 cups
Houston 491 cups
[160, 131, 118]
Dallas sold 131 cups on Friday, the weekly totals are 685, 545 and 491 cups, and the Friday column is [160, 131, 118].
