Skip to content
Advertisement

Nested List of Lists to Single List of tuples

I’m trying to turn a nested list of lists (number of lists can be 2 lists +) into a single list of tuples.

The list looks something like this:

JavaScript

And I would like for it to be like this:

JavaScript

I know that if you do zip(list1, list2), it becomes a list of tuple. But how do I go about doing it for a list of lists?

I tried using the zip concept with:

JavaScript

But it did not work out for me.

Advertisement

Answer

JavaScript

Edit:

If you want your output to be a list of lists, instead of a list of tuples,

JavaScript

should do the trick

Advertisement