0

I want to generate some NumPy arrays with their names to be assigned to from a list of names. This is going to happen in a for-loop. The names are from a list. How can I do that?

For example, we have list = [ 'LA', 'SD', 'SB'], the eventually in a loop I want to have

LA = np.zeros([m,n])

loop 1 loop 2

LA = np.array(...)

Do you know how to do that?

Pedram920
  • 1
  • 2

1 Answers1

0

I think u should use exec for that

for name in list:
   exec(name + "= np.zeros([m, n])"
David
  • 149
  • 1
  • 9