Lists
How to convert a tuple to a list in Python
Quick answer
Use list() or the list() function to convert a tuple to a list, like list(my_tuple).
my_tuple = (1, 2, 3)
my_list = list(my_tuple)
print(my_list)The snippet converts a tuple to a list using the list() function. This approach wins because it is straightforward and efficient. A real gotcha is that the list() function does not work with nested tuples.
Variations
Alternate Approach
my_list = [*my_tuple]uses unpacking
Edge Case
my_list = list(my_tuple)
if not my_list:
print('empty')handles empty tuples
Related Pattern
my_set = set(my_tuple)converts to set
Get one Python lesson + one career idea every Friday
No spam, no "buy our course now". Three bullets, every Friday. Unsubscribe with one click.