Me aparece este error, no se por qué :(
Traceback (most recent call last):
File "pruebaError.py", line 25, in <module>
print(mostrarT())
File "pruebaError.py", line 22, in mostrarT
if(t[i][j].getVar() == False):
TypeError: getVar() takes 0 positional arguments but 1 was given
Este es el código:
class A:
var = False
def __init__(self,var):
self.var = var
def getVar():
return var
t = []
for i in range(8):
t.append([None])
for j in range(8):
t[i].append(None)
for i in range(8):
for j in range(8):
t[i][j] = A(True)
def mostrarT():
cantFalse = 0
for i in range(8):
for j in range(8):
if(t[i][j].getVar()):
cantFalse += 1
return cantFalse
print(mostrarT())
getVar
como estático, agregar@staticmethod
antes del def, o pasarle self como parámetrodef getVar(self):