Can you help me getting the correct output. I want to call P2, by combining P and 2, for a value of 34?
I assigned P2 = 34 , but if I want to combine P and 2 in M and I call M, I only get P2 as a string not a variable. I get that it happens, but I don't know how to solve it.
i=2
P2 = 34
M = 'P%s'%(int(i))
print(M)
print(P2)
Output:
P2
34
Expected output:
34
34
I will try to further explain my problem.
I have 3 matrices all are 3 by 3. They are called P1, P2, P3
I want to call each element of each matrix therefor I tried
for p in range(3):
for i in range(3):
for j in range(3):
M = 'P%s'%(int(p))
print(M[i,j])
Is it still the same problem of not using dict?