How to Convert Tuple to List in Python
We know that Lists are mutable objects while tuples are immutable. There is a built-in Python list method list() that can be used for converting Tuples to Lists. This method list() takes sequence types and converts them to lists.
Tuples are very similar to lists with the only difference that element values of a tuple can not be changed and tuple elements are put between parentheses instead of square bracket.
color = ("red", "green", "blue") print(color) print(type(color)) color_list = list(color) print(color_list) print(type(color_list))
('red', 'green', 'blue') <class 'tuple'> ['red', 'green', 'blue'] <class 'list'>
Please login to comment
View all comments