Is there a way to flatten values of a nested list but alternately?
example:
nested_list = [[1, 3, 5], [2, 4]]
my expected output would be:
[1, 2, 3, 4, 5]
>Solution :
Use hstack from numpy
import numpy as np
nested_list = [[1, 3, 5], [2, 4]]
new_nested_list = np.hstack(nested_list)
now new_nested_list is equal to [1 3 5 2 4]