Python – List of tuples to multiple lists

• Last Updated : 23 Aug, 2021

In this article, we will discuss how to convert a List of tuples to multiple lists. We can convert lit of tuples to multiple lists by using the map() function

Syntax: map(list, zip(*list_of_tuples)

Example:

```Input: [('a', 'b', 'c'), (1,2,3), ('1','3','4')]
Output: ['a', 'b', 'c'], [1, 2, 3], ('1', '3', '4')```

Example 1: Python code to display a list of tuples and display them.

Python3

 `# list of tuple for student data``# with both integer and strings``a ``=` `[(``1``, ``2``,``3``,``4``,``5``),``     ``(``"sravan"``,``"bobby"``,``"ojaswi"``,``"rohith"``,``"Gnanesh"``), ``     ``(``96``,``89``,``78``,``90``,``78``)]`` ` `# display``print``(``"Original list of tuple"``)``print``(a)`` ` `# list of tuple for student data ``# with both integer and strings``a ``=` `[(``1``, ``2``,``3``,``4``,``5``),``     ``(``"sravan"``,``"bobby"``,``"ojaswi"``,``"rohith"``,``"Gnanesh"``),``     ``(``96``,``89``,``78``,``90``,``78``)]`` ` `# convert list of tuple to multiple lists``data ``=` `map``(``list``, ``zip``(``*``a))`` ` `print``("")`` ` `# display ``print``(``"List"``)``for` `i ``in` `data:``  ``print``(i)`

Output:

Original list of tuple

[(1, 2, 3, 4, 5), (‘sravan’, ‘bobby’, ‘ojaswi’, ‘rohith’, ‘Gnanesh’), (96, 89, 78, 90, 78)]

List

[1, ‘sravan’, 96]

[2, ‘bobby’, 89]

[3, ‘ojaswi’, 78]

[4, ‘rohith’, 90]

[5, ‘Gnanesh’, 78]

Example 2: Python code to convert a list of tuples to multiple lists

Python3

 `# list of tuple for student``# data with both integer and strings``a ``=` `[(``1``, ``2``,``3``,``4``,``5``), ``     ``(``"sravan"``,``"bobby"``,``"ojaswi"``,``"rohith"``,``"Gnanesh"``),``     ``(``96``,``89``,``78``,``90``,``78``),``     ``(``"kakumanu"``,``"kakumanu"``,``"hyd"``,``"hyd"``,``"hyd"``)]`` ` `# convert list of tuple to multiple lists``data ``=` `map``(``list``, ``zip``(``*``a))`` ` `# display ``for` `i ``in` `data:``  ``print``(i)`

Output:

```[1, 'sravan', 96, 'kakumanu']
[2, 'bobby', 89, 'kakumanu']
[3, 'ojaswi', 78, 'hyd']
[4, 'rohith', 90, 'hyd']
[5, 'Gnanesh', 78, 'hyd']```

My Personal Notes arrow_drop_up