list to tuple code example

Example 1: list of tuple to tuple of list python

>>> source_list = [('1','a'),('2','b'),('3','c'),('4','d')]
>>> list1, list2 = zip(*source_list)
>>> list1
('1', '2', '3', '4')
>>> list2
('a', 'b', 'c', 'd')

Example 2: converting a tuple to a list in python

#!/usr/bin/python

aTuple = (123, 'xyz', 'zara', 'abc');
aList = list(aTuple)
print "List elements : ", aList

Example 3: python tuple convert to list

x = list(x)

Example 4: convert a list to tuple

tuple_name=tuple(list_name)