if (a % 2 == 0 and b % 2 == 0) or (a % 2 == 0 and b % 3 == 0):
pav=0
pas=1
for i in range(a):
for j in range(b):
if(matrix[i][j]==0 and i+1<=a and j+1<=b):
if(matrix[i][j+1]==0 and matrix[i+1][j]==0):
a[i][j]=a[i][j+1]=a[i+1][j]=pas
pas+=1
pav+=1
if matrix[i+1][j+2]==0:
if(matrix[i][j+2]==0 and matrix[i+1][j+1]==0):
matrix[i+1][j+2]=matrix[i][j+2]=matrix[i+1][j+1]=pas
pas+=1
pav+=1
Traceback (most recent call last):
File "C:/Users/Loading/PycharmProjects/Test/test.py", line 14, in example.check_numbers(matrix,a, b)
File "C:\Users\Loading\PycharmProjects\Test\venv\example.py", line 30, in check_numbers a[i][j]=a[i][j+1]=a[i+1][j]=pas
TypeError: 'int' object is not subscriptable
a[i][j]=a[i][j+1]=a[i+1][j]=pas
This line. You are treating a
as an array, and yet you clearly have it defined as an integer outside of the code snippet as you are using modulus with it.
Whenever you get the error object is not subscriptable
it means you are trying to treat an object as an array.