If you’re short on time, here’s my quick take on how to convert a Python tuple to a Python list?
The most Pythonic way to convert a tuple to a list in Python is to call the built-in
list() function and pass the tuple as a function argument to the function. The function
list() takes any sequence type such as a tuple and converts them to lists. The return value of the function is the new list generated.
t = (1, 2, 3) l = list(t) print(l) # [1, 2, 3]
There are some details to this approach—and alternative ways as well. Feel free to keep reading, watch the article video, and improve your Python skills in the process! 🙂
Let’s get started!
Problem Formulation + Examples
- Convert tuple
(1, 2, 3, 4, 5)to list
[1, 2, 3, 4, 5].
- Convert tuple
('Alice', 'Bob', 'Ann')to list
['Alice', 'Bob', 'Ann'].
- Convert tuple
Note Tuple: Tuples are similar to lists—with the difference that you cannot change the tuple values (tuples are immutable) and you use parentheses
(...) rather than square brackets
This article shows five solutions to this problem of converting a tuple
t to a new list:
for el in t: new_list.append(el)
[x for x in t]
Method 1: list()
Solution: Use the built-in Python
list() function to convert a list into a tuple. You don’t need to import any external library.
Code: The following code converts the three given tuples into lists.
tuple_1 = (1, 2, 3, 4, 5) print(list(tuple_1)) # [1, 2, 3, 4, 5] tuple_2 = ('Alice', 'Bob', 'Ann') print(list(tuple_2)) # ['Alice', 'Bob', 'Ann'] tuple_3 = (1,) print(list(tuple_3)) # 
Explanation: You can see that converting a tuple with one element leads to a list with one element. The
list() function is the easiest way to convert a tuple into a list. Note that the values in the tuple are not copied—only a new reference to the same element is created:
The graphic also shows how to convert a tuple back to a list by using the
tuple() function (that’s also a Python built-in function). Thus, calling
list(tuple(lst)) on a list
lst will result in a new list with the same elements.
Try to execute this code with the interactive Python tutor:
Method 2: Loop Iteration + append()
To convert a tuple to a list, start with an empty list and fill in one tuple element at a time using the
append() method and pass the tuple element into the function within a Python loop body iterating over all tuple elements.
Here’s the code to do this:
def tuple_to_list(t): new_list =  for element in t: new_list.append(element) return new_list tuple_1 = (1, 2, 3, 4, 5) print(tuple_to_list(tuple_1)) # [1, 2, 3, 4, 5] tuple_2 = ('Alice', 'Bob', 'Ann') print(tuple_to_list(tuple_2)) # ['Alice', 'Bob', 'Ann'] tuple_3 = (1,) print(tuple_to_list(tuple_3)) # 
You can learn more about the
append() method in my detailed guide and the accompanying video:
Method 3: Unpacking Asterisk Operator
To convert a tuple to a list, you can use the unpacking asterisk operator * from Python version 3.5 onwards. For example, the expression
[*t] creates a new list with the square bracket notation and unpacks all elements of the tuple
t into the list.
Here’s the code to accomplish this:
def tuple_to_list(t): return [*t] tuple_1 = (1, 2, 3, 4, 5) print(tuple_to_list(tuple_1)) # [1, 2, 3, 4, 5] tuple_2 = ('Alice', 'Bob', 'Ann') print(tuple_to_list(tuple_2)) # ['Alice', 'Bob', 'Ann'] tuple_3 = (1,) print(tuple_to_list(tuple_3)) # 
[*t] is the most concise one-liner to convert a tuple
t to a list!
Method 4: List Comprehension
The list comprehension statement
[x for x in t] converts a Python tuple
t into a new list by iterating over all elements
x in the tuple
t and placing them unchanged in the list using the square bracket notation
Here’s the code:
def tuple_to_list(t): return [x for x in t] tuple_1 = (1, 2, 3, 4, 5) print(tuple_to_list(tuple_1)) # [1, 2, 3, 4, 5] tuple_2 = ('Alice', 'Bob', 'Ann') print(tuple_to_list(tuple_2)) # ['Alice', 'Bob', 'Ann'] tuple_3 = (1,) print(tuple_to_list(tuple_3)) # 
If you need a quick refresher on list comprehension, feel free to check out my detailed guide on the Finxter blog.
Method 5: Convert Tuple of Tuples to List of Lists
If you have a tuple of tuples such as
((1, 2, 3), (4, 5, 6)) you can convert it to a list of lists such as
[[1, 2, 3], [4, 5, 6]] by combining list comprehension with the
list() function like so:
[list(x) for x in t]
Here’s a simple code example:
def tuple_to_list(t): return [list(x) for x in t] tuple_1 = ((1, 2, 3), (4, 5, 6, 7, 8, 9), ('Alice', 'Bob', 'Carl')) print(tuple_to_list(tuple_1)) # [[1, 2, 3], [4, 5, 6, 7, 8, 9], ['Alice', 'Bob', 'Carl']]
Programmer Humor – Blockchain
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.