How to convert a tuple to list in Python [16 different ways]

In this Python tutorial, we will discuss how to convert a tuple to a list in python.

There are more than 10 ways to convert the given tuple to a list in Python. These are methods are shown below.

  1. Using the built-in function list()
  2. Using a for loop
  3. Using the list comprehension
  4. Using the * operator
  5. Using list constructor with iterable
  6. Using map function and list constructor
  7. Using reduce function of functools module
  8. Using chain method of itertools module
  9. Using the sum function
  10. Using a lambda function
  11. Using the zip function
  12. Using the eval function
  13. Using nested for loops
  14. Using a recursive method
  15. Using the enumerate function
  16. Using the map() and eval()

Python convert tuple to list

Here we will discuss various different methods to convert Python Tuple to a list. And first, we will discuss how to the list() built-in function in Python for this task.

Method-1: Convert Python tuple to list using the built-in function list()

This method uses the built-in list function, which takes an iterable as an argument and returns a list. Simply passing a tuple as an argument to the list function will convert it into a list.

# Define a tuple with values 10, 20, 30, 40, 50
value = (10, 20, 30, 40, 50)

# Convert the tuple to a list
my_tuple = list(value)

# Print the list
print(my_tuple)

The above code defines a tuple value with the values 10, 20, 30, 40, 50. It then converts the tuple to a list my_tuple using the list() function.

  • Finally, it prints the list with the print() function. The output will be the list [10, 20, 30, 40, 50].
Python convert tuple to list
Python convert tuple to list

Read: Convert an integer to a string in python

Method-2: Using a for loop

This method uses a for loop to iterate through each element in the tuple, and append each element to a new list. This creates a new list with the same elements as the original tuple.

# Define a tuple countries
countries = ("United Kingdom", "USA", "Canada", "Brazil")

# Create an empty list to store the elements of the tuple
lst = []

# Loop through each element in the tuple
for i in countries:
    # Append each element to the list
    lst.append(i)

# Print the list
print(lst)

The code defines a tuple countries with the country names “United Kingdom”, “USA”, “Canada”, “Brazil”. It then creates an empty list lst to store the elements of the tuple.

  • The code then loops through each element in the tuple using a for loop and appends each element to the list lst using the append method.
  • Finally, it prints the list with the print() function. The output will be the list [‘United Kingdom’, ‘USA’, ‘Canada’, ‘Brazil’].
Output: ['United Kingdom', 'USA', 'Canada', 'Brazil']

Read: How to convert a dictionary into a string in Python

Method-3: Using the list comprehension

This method uses a concise and efficient syntax for creating a list from an iterable, called a list comprehension. Simply provide the iterable as the input for the list comprehension, and each element of the iterable will be added to the new list.

# Define a tuple with country names
t = ("USA", "Brazil", "United Kingdom", "Canada")

# Create a list of the elements of the tuple using a list comprehension
lst = [i for i in t]

# Print the list
print(lst)

The above code defines a tuple t with the country names “USA”, “Brazil”, “United Kingdom”, “Canada”.

  • It then creates a list lst using a list comprehension that loops through each element in the tuple t and appends each element to the list lst.
  • Finally, it prints the list with the print() function.
Output: ['USA', 'Brazil', 'United Kingdom', 'Canada']

Read: Python epoch to DateTime

Method-4: Using the * operator

This method uses the * operator to unpack the elements of the tuple and add them to a new list. The * operator allows you to pass multiple arguments to a function or unpack a list or tuple into separate elements.

# Define a tuple with country names
t = ("USA", "Brazil", "United Kingdom", "Canada")

# Create a list from the tuple using the "unpacking" operator *
lst = [*t]

# Print the list
print(lst)

The above code defines a tuple t with the country names “USA”, “Brazil”, “United Kingdom”, “Canada”.

  • It then creates a list lst using the “unpacking” operator * to unpack the elements of the tuple into the list. Finally, it prints the list with the print() function.
Python convert tuple to list using asterisk operator
Python convert tuple to list using asterisk operator

Read: Python string to list

Method-5: Using list constructor with iterable

This method uses the list constructor to create a list from an iterable, specifically using the iter function to create an iterator from the tuple.

  • The list constructor takes an iterable as an argument, so passing the result of iter(t) to the list constructor will convert the tuple into a list.
# Define a tuple with country names
t = ("USA", "Brazil", "United Kingdom", "Canada")

# Convert the tuple to a list using the built-in function `list` and the `iter` function
lst = list(iter(t))

# Print the list
print(lst)

The above code defines a tuple t with the country names “USA”, “Brazil”, “United Kingdom”, “Canada”.

It then creates a list lst using the list function and passing the tuple to the iter function. Finally, it prints the list with the print() function.

Output: ['USA', 'Brazil', 'United Kingdom', 'Canada']

Read: Python dictionary values to list 

Method-6: Using map function and list constructor

This method uses the map function to apply a function to each element of the tuple, and then uses the list constructor to convert the result of the map function into a list.

  • In this case, the function passed to map is the identity function, which simply returns each element unchanged.
# Define a tuple with country names
t = ("USA", "United Kingdom", "Canada","Brazil")

# Convert the tuple to a list using the `list` function and the `map` function with a lambda function
lst = list(map(lambda x: x, t))

# Print the list
print(lst)

The above code defines a tuple t containing country names. It then converts the tuple to a list using the list function and the map function with a lambda function that returns the input element x. Finally, the code prints the resulting list.

Output: ['USA', 'United Kingdom', 'Canada', 'Brazil']

Method-7: Using reduce function of functools module

This method uses the reduce function from the functools module to iteratively apply a binary function to the elements of the tuple, and build a new list from the results.

# Import the reduce function from the functools module
from functools import reduce

# Define a tuple of country names
t =  ("USA", "United Kingdom", "Canada","Brazil")

# Convert the tuple to a list using the reduce function
lst = reduce(lambda x, y: x + [y], t, [])

# Print the resulting list
print(lst)

This code imports the reduce function from the functools module and defines a tuple t with 4 elements. Then it uses the reduce function with a lambda function to convert the tuple t into a list.

Output: ['USA', 'United Kingdom', 'Canada', 'Brazil']

Read: Python convert dictionary to an array

Method-8: Using chain method of itertools module

This method uses the chain method from the itertools module to concatenate the elements of the tuple into a single iterable, and then uses the list constructor to convert the result into a list.

# Import the chain method from itertools
from itertools import chain

# Define a tuple of countries
t = ("USA", "United Kingdom", "Canada","Brazil")

# Convert the tuple to a list using the chain method
lst = list(chain(t))

# Print the resulting list
print(lst)

The above code is converting a tuple t into a list lst by using the chain function from the itertools module.

  • The chain function takes an iterable as input and returns a single, flattened list from all elements in the iterables. Here, the tuple t is passed as the input to chain and the result is assigned to the list lst.
  • Finally, the list lst is printed.
Output: ['USA', 'United Kingdom', 'Canada', 'Brazil']

Method-9: Using the sum function

This method uses the sum function to concatenate the elements of the tuple into a single list. The sum function takes an iterable of numbers as an argument and returns the sum of all the elements in the iterable.

# Import the sum function from the built-in python library
from builtins import sum

# Define a tuple of countries
t = ("USA", "United Kingdom", "Canada","Brazil")

# Create a list from the elements of the tuple
# The sum function is used to concatenate the list of lists into a single list
lst = sum([[x] for x in t], [])

# Print the final list
print(lst)

The above code is converting a tuple t containing elements “USA”, “United Kingdom”, “Canada”, and “Brazil” into a list lst.

  • The sum function is used to concatenate a list comprehension that converts each element of the tuple into a single-element list, into an empty list [].
  • Finally, the resulting list lst is printed.
Output: ['USA', 'United Kingdom', 'Canada', 'Brazil']

Read: How to convert dictionary to JSON in Python

Method-10: Using a lambda function

This method uses a lambda function to map each element of the tuple to a list, and then uses the sum function to concatenate the lists into a single list.

  • The lambda function takes a single argument and returns a list with that argument as its only element.
# Define a tuple t with elements "USA", "United Kingdom", "Canada","Brazil"
t = ("USA", "United Kingdom", "Canada","Brazil")

# Convert each element in the tuple t to a list and store the result in a list
lst = sum(map(lambda x: [x], t), [])

# Print the list
print(lst)

The above code converts each element in the tuple t to a list and stores the result in a list lst.

  • The map function is used to apply the lambda function to each element of the tuple, which takes an element x and returns a list containing x.
  • The sum function is then used to concatenate the list of lists into a single list. The final result is printed on the console.
Output: ['USA', 'United Kingdom', 'Canada', 'Brazil']

Method-11: Using the zip function

This method uses the zip function to create pairs of elements from the tuple and a sequence of integers, and then uses a list comprehension to extract the elements of the tuple into a single list.

# Define a tuple t
t = ("USA", "United Kingdom", "Canada","Brazil")

# Use a list comprehension to convert each element of the tuple into a single element list
# Use zip to create a list of tuples where each tuple contains an element from t and its index
# Unpack each tuple into x and _ and store x in a list
lst = [x for x, _ in zip(t, range(len(t)))]

# Print the list
print(lst)

The above code defines a tuple t containing four elements. The code then creates a list lst using a list comprehension that loops through each element in the tuple t, and for each element, it creates a list [x] and assigns the value of the current element to x. Finally, the code prints the resulting list.

Output: ['USA', 'United Kingdom', 'Canada', 'Brazil']

Method-12: Using the eval function

This method uses the eval function to evaluate a string representation of the tuple as a Python expression and then converts the resulting tuple into a list.

# Code to convert a tuple to list

# Define the tuple t
t = ("USA", "Canada","United Kingdom", "Brazil")

# Convert the tuple to a string representation and then use the built-in eval function to evaluate the string as a list
lst = list(eval(str(t)))

# Print the resulting list
print(lst)

The code defines a tuple t and converts it to a list lst using the eval() function.

  • The str() function is used to convert the tuple to a string representation, which is then passed as an argument to eval() to be evaluated and converted back to a list.
  • Finally, the list is printed.
Output: ['USA', 'Canada', 'United Kingdom', 'Brazil']

Method-13: Using nested for loops

This method uses nested for loops to iterate over the elements of the tuple and append each element to a list.

# List of tuple initialization
t = [('apple', 1), ('banana', 2), ('cherry', 3)]

# using nested for loops
out = []
for tpl in t:
    for item in tpl:
        out.append(item)

# printing output
print(out)

This code defines a list of tuples, t, containing (fruit name, number) pairs. It then uses nested for loops to iterate over each tuple in t, and each item within each tuple. Each item is appended to a new list, out, which is finally printed.

Output: ['apple', 1, 'banana', 2, 'cherry', 3]

Method-14: Using a recursive method

This method uses a recursive function to convert a tuple into a list. The function takes a tuple as an argument and returns a list.

  • If the tuple is empty, the function returns an empty list.
  • If the tuple has only one element, the function returns a list containing that element.
  • If the tuple has more than one element, the function returns a list containing the first element followed by the result of calling the function on the rest of the tuple.
# Define a function to convert tuple to list
def tuple_to_list(t):
    # Base case: if the tuple is empty, return an empty list
    if not t:
        return []
    # Base case: if the tuple only has one item, return a list with that item
    if len(t) == 1:
        return [t[0]]
    # Recursive case: append the first item of the tuple to the result of 
    # calling the function with the rest of the tuple
    return [t[0]] + tuple_to_list(t[1:])

# Initialize a tuple
t = (1, 2, 3, 4)
# Call the function to convert the tuple to list
lst = tuple_to_list(t)
# Print the result
print(lst)

The above code defines a function called tuple_to_list that takes in a tuple as its argument t.

  • The function uses a recursive approach to convert the input tuple into a list.
Output: [1, 2, 3, 4]

Method-15: Using the enumerate function

This method uses the enumerate function to convert a tuple into a list. The enumerate function returns an iterable that produces pairs of indices and elements from the input iterable.

  • In this case, the input iterable is the tuple that you want to convert to a list.
# This code defines a tuple "t" which contains four elements
t = ("USA", "Canada","United Kingdom", "Brazil")

# The list "lst" is constructed using a list comprehension that iterates over the elements in "t"
# The enumerate function is used to get the index and value of each element in "t"
# The list comprehension uses the value of each element and discards the index
lst = [x for i, x in enumerate(t)]

# The resulting list "lst" is printed
print(lst)

This code takes a tuple t of strings and converts it into a list lst.

  • The conversion is done using a list comprehension that iterates over the elements of the tuple and their indices i using enumerate(t), and appends each element x to the list lst.
  • Finally, the resulting list lst is printed.
Output: ['USA', 'Canada', 'United Kingdom', 'Brazil']

Method-16: Using the map() and eval()

This method uses the map function to apply the eval function to each element of the tuple, converting each element from a string representation of a Python object to an actual Python object. The code then uses the list function to convert the resulting map object to a list.

# code to convert a tuple to a list using map

# Tuple Initialization
t = ('1', '2.5', '3', '4.2')

# Using map to convert tuple elements to list
lst = list(map(eval, t))

# Printing the list
print(lst)

The above code defines a tuple t consisting of 4 elements. The elements of the tuple are then converted to a list using map() function along with eval().

  • The eval() function evaluates an expression and returns the value. The resulting list is then printed.
Output: [1, 2.5, 3, 4.2]

Also, check the following python tutorials.

In this tutorial, we learned how to convert tuple to list in Python, Python convert tuple to list by following methods:

  • Python convert tuple to list using the built-in function list()
  • How to convert tuple to list using a for loop in Python
  • Python convert tuple to list using the list comprehension
  • Python convert tuple to list using the * operator
  • Python convert tuple to list using list constructor with iterable
  • Python convert tuple to list using map function and list constructor
  • Python convert tuple to list using reduce function of functools module
  • Python convert tuple to list using chain method of itertools module
  • Python convert tuple to list using the sum function
  • Python convert tuple to list using a lambda function
  • Python convert tuple to list using the zip function
  • Python convert tuple to list using the eval function
  • Python convert tuple to list using nested for loops
  • Python convert tuple to list using a recursive method
  • Python convert tuple to list using the enumerate function
  • Python convert tuple to list using the map() and eval()