I have a very simple program in python to check if a list has a zero value in it
class ZeroList(object):
def __init__(self,coordinates):
self.coordinates = coordinates
def is_zero(value):
return math.isclose(value,0)
def test(self):
for coord in self.coordinate:
if not is_zero(coord):
print(coord)
a = ZeroList([1,2,0,8,5,0,3,7,0,3])
a.test()
Yet running this results in the error
Traceback (most recent call last):
File "line2.py", line 2, in <module>
class Test(object):
File "line2.py", line 12, in Test
test([1,2,3])
File "line2.py", line 8, in test
if not is_zero(i):
NameError: name 'is_zero' is not defined
The method is_zero is clearly defined so why is this error showing up?