I'm trying to assign X name to N variables, through basic functions. I've been searching for the key but I always find the same answer:
Thats a bad idea, why dont u use a dictionary...
def create_matrix(m,nf,nc):
m = np.empty((nf,nc), dtype=np.int)
for i in range(nf):
for j in range(nc):
m[i][j] = int(input('Value: '))
i'd like to build N "matrices", i need to declare m = np.empty((nf,nc), dtype=np.int) before each one, the answer is, How could i "dinamize" that funcition in order to operate later with them? F.E:
create_matrix1(m1,2,3) create_matrix2(m2,2,3) . . . create_matrixn(mn,2,3) m1 + m2 + m5 = x
Thanks in advance
Well, that works, thank you!
>>> mats
[array([[1, 2],
[3, 4]]), array([[5, 6],
[7, 8]]), array([[ 9, 10],
[11, 12]])]
Now I'm trying to figure how to refer mats[1(x,y)] in order to operate with them
>>> mats[1[[1][1]]]
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
mats[1[[1][1]]]
IndexError: list index out of range
>>> mats[1[1][1]]
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
mats[1[1][1]]
TypeError: 'int' object is not subscriptable
You are right, again.
>>> mats[1][1][1]
8
I thought i tried every posibility, i think im tired, time to sleep.
Thank you very much!