Skip to content
Advertisement

Convert List of list into tuple of tuples

I have a list of 2x1 matrices like:

JavaScript

I need to convert it into a tuple of tuples, like:

JavaScript

I know I can loop through the list and convert it manually , trying to check if there is a better-optimized way of doing it.

Advertisement

Answer

You can do it this way using numpy indexing and slicing that outer dimension.

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement