Skip to content
Advertisement

alternately flatten values of nested list

Is there a way to flatten values of a nested list but alternately?

example:

JavaScript

my expected output would be:

JavaScript

Advertisement

Answer

You can do it without numpy using iterators and keep track when the list stops growing:

JavaScript

IF you have None values in your list, you need to choose another sentinel value.

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