I am brand new to python. I got a error
JavaScript
x
3
1
while not cls.isFilled(row,col,myMap):
2
TypeError: 'bool' object is not callable
3
Would you please instruct how to solve this issue? The first “if” check is fine, but “while not” has this error.
JavaScript
1
23
23
1
def main(cls, args):
2
3
if cls.isFilled(row,col,myMap):
4
numCycles = 0
5
6
while not cls.isFilled(row,col,myMap):
7
numCycles += 1
8
9
10
def isFilled(cls,row,col,myMap):
11
cls.isFilled = True
12
## for-while
13
i = 0
14
while i < row:
15
## for-while
16
j = 0
17
while j < col:
18
if not myMap[i][j].getIsActive():
19
cls.isFilled = False
20
j += 1
21
i += 1
22
return cls.isFilled
23
Advertisement
Answer
You do cls.isFilled = True
. That overwrites the method called isFilled
and replaces it with the value True. That method is now gone and you can’t call it anymore. So when you try to call it again you get an error, since it’s not there anymore.
The solution is use a different name for the variable than you do for the method.