I am trying to initialize a list of numpy arrays in the following way
import numpy as np
sol=[np.zeros(5)]*4
But when I try to modify one of the list members like this,
sol[0][2:4]=[1,1]
It changes all the list members instead of only the first one
[array([ 0., 0., 1., 1., 0.]), array([ 0., 0., 1., 1., 0.]), array([ 0., 0., 1., 1., 0.]), array([ 0., 0., 1., 1., 0.])]
I guess it is old story about mutable and inmutable objects, but I simply don't know how to solve it.
I tried using copy and deepcopy, but not successful.
Sorry if it is duplicated entry, but I couldn't find any similar question
Thanks