Skip to content
Advertisement

How to convert a array of array to array of tuples

I everyone,

I struggle to convert an array of array like this :

JavaScript

to an array of tuples (array, str) like this:

JavaScript

I did find a way to append the type to the array but it’s not exactly what I want:

JavaScript

Do you have something better ? Thanks :)

Advertisement

Answer

Solution

Shortest solution: list(zip(vals, types)) 🔥🔥🔥

JavaScript

Output:

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