Answer: The simplest, most straightforward, and most readable way to convert a tuple to a list is Python’s built-in
list(tuple) function. You can pass any iterable (such as a tuple, another list, or a set) as an argument into this so-called constructor function and it returns a new list data structure that contains all elements of the iterable.
Converting a tuple to a list seems trivial, I know. But keep reading and I’ll show you surprising ways of handling this problem. I guarantee that you’ll learn a lot of valuable things from the 3-5 minutes you’ll spend reading this tutorial! 🙂
Problem: Given a tuple of elements. Create a new list with the same elements—thereby converting the tuple to a list.
Example: You have the following tuple.
t = (1, 2, 3)
You want to create a new list data structure that contains the same integer elements:
[1, 2, 3]
Let’s have a look at the different ways to convert a tuple to a list—and discuss which is the most Pythonic way in which circumstance.
You can get a quick overview in the following interactive code shell. Explanations for each method follow after that:
Exercise: Run the code. Skim over each method—which one do you like most? Do you understand each of them?
Let’s dive into the six methods.
Method 1: List Constructor
The simplest, most straightforward, and most readable way to convert a tuple to a list is Python’s built-in
list(iterable) function. You can pass any iterable (such as a list, a tuple, or a set) as an argument into this so-called constructor function and it returns a new tuple data structure that contains all elements of the iterable.
Here’s an example:
# Method 1: list() constructor t = (1, 2, 3) lst = list(t) print(lst) # [1, 2, 3]
This is the most Pythonic way if a flat conversion of a single tuple to a list is all you need. But what if you want to convert multiple tuples to a single list?
Method 2: Unpacking
There’s an alternative that works for one or more tuples to convert one or more tuples into a list. This method is equally efficient and it takes less characters than Method 1 (at the costs of readability for beginner coders). Sounds interesting? Let’s dive into unpacking and the asterisk operator!
The asterisk operator
* is also called “star operator” and you can use it as a prefix on any tuple (or list). The operator will “unpack” all elements into an outer structure—for example, into an argument lists or into an enclosing container type such as a list or a tuple.
Here’s how it works to unpack all elements of a tuple into an enclosing list—thereby converting the original tuple to a new list.
# Method 2: Unpacking t = (1, 2, 3) lst = [*t] print(lst) # [1, 2, 3]
You unpack all elements in the tuple
t into the outer structure
[*t]. The strength of this approach is—despite being even conciser than the standard
list(...) function—that you can unpack multiple values into it!
Method 3: Unpacking to Convert Multiple Tuples to a Single List
Let’s have a look at how you’d create a list from multiple tuples:
# Method 3: Unpacking Multiple Tuples t1 = (1, 2, 3) t2 = (4, 5, 6) lst = [*t1, *t2] print(lst) # [1, 2, 3, 4, 5, 6]
[*t1, *t2] unpacks all elements in tuples
t2 into the outer list. This allows you to convert multiple tuples to a single list.
Method 4: Generator Expression to Convert Multiple Tuples to List
If you have multiple tuples stored in a list of lists (or list of tuples) and you want to convert them to a single list, you can use a short generator expression statement to go over all inner tuples and over all elements of each inner tuple. Then, you place each of those elements into the list structure:
# Method 4: Generator Expression ts = ((1, 2), (3, 4), (5, 6, 7)) lst = [x for t in ts for x in t] print(lst) # [1, 2, 3, 4, 5, 6, 7]
This is the most Pythonic way to convert a list of tuples (or tuple of tuples) to a tuple. It’s short and efficient and readable. You don’t create any helper data structure that takes space in memory.
But what if you want to save a few more characters?
Method 5: Generator Expression + Unpacking
Okay, you shouldn’t do this last method using the asterisk operator—it’s unreadable—but I couldn’t help including it here:
# Method 5: Generator Expression + Unpacking t = ((1, 2), (3, 4), (5, 6, 7)) lst = [*(x for t in ts for x in t)] print(lst) # [1, 2, 3, 4, 5, 6, 7]
Rather than using the
list(...) function to convert the generator expression to a list, you use the
[...] helper structure to indicate that it’s a list you want—and unpack all elements from the generator expression into the list. Sure, it’s not very readable—but you could see such a thing in practice (if pro coders want to show off their skills ;)).
Method 6: Simple For Loop
Let’s end this article by showing the simple thing—using a for loop. Doing simple things is an excellent idea in coding. And, while the problem is more elegantly solved in Method 1 (using the
list() constructor), using a simple loop to fill an initially empty list is the default strategy.
# Method 6: Simple For Loop t = (1, 2, 3, 4) lst =  for x in t: lst.append(x) print(lst) # [1, 2, 3, 4]
To understand how the code works, you can visualize its execution in the interactive memory visualizer:
Exercise: How often is the loop condition checked?
You will see such a simple conversion method in code bases of Python beginners and programmers who switch to Python coming from other programming languages such as Java or C++. It’s readable but it lacks conciseness.
I hope you liked the article! Please find related articles here:
If you want to boost your Python skills, I’ve created an online academy that’s entirely based on email (and it’s free).
Where to Go From Here?
Enough theory. Let’s get some practice!
Coders get paid six figures and more because they can solve problems more effectively using machine intelligence and automation.
To become more successful in coding, solve more real problems for real people. That’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?
You build high-value coding skills by working on practical coding projects!
Do you want to stop learning with toy projects and focus on practical code projects that earn you money and solve real problems for people?
🚀 If your answer is YES!, consider becoming a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.
If you just want to learn about the freelancing opportunity, feel free to watch my free webinar “How to Build Your High-Income Skill Python” and learn how I grew my coding business online and how you can, too—from the comfort of your own home.
While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com. He’s author of the popular programming book Python One-Liners (NoStarch 2020), coauthor of the Coffee Break Python series of self-published books, computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.