Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to map two tuples into a list of tuple in python?

I want to map two tuples into a new list in python. One To One relation between that two tuples and then convert that into list.

tup_1 = (1, 2, 3)
tup_2 = (4, 5, 6)
x = map(tup_1, tup_2)
>>> x
[(1, 4), (2, 5), (3, 6)]

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I want to map two tuples into a new list in python.

It is very easy in python, just use zip function of python, that will give you an iterative object. Convert that object into list using list function of python.

tup_1 = (1, 2, 3)
tup_2 = (4, 5, 6)
x = list(zip(tup_1, tup_2))
>>> x
[(1, 4), (2, 5), (3, 6)]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading