Reputation: 71
For example I have a tuple (1,2,3)
, how to convert it into [(1,2,3)]
?
I tried list
method but it seems doesn't work.
l = (1,2,3) -> l =[(1,2,3)]
Upvotes: 2
Views: 87
Reputation: 975
Create an empty list and append tuple to it.
>>>t = (1,2,3)
>>>a = []
>>>a.append(t)
>>>a
[(1,2,3)]
>>>
Upvotes: 0
Reputation: 937
l_tuple = (1, 2, 3)
l_list = [l_tuple]
l_list_items = list(l_tuple)
>>> print l_list
[(1, 2, 3)]
>>> print l_list_items
[1, 2, 3]
Not that there is a difference between using the square braces and the list()
function to construct your list.
Upvotes: 0