I have a class and am trying to create a function inside of a function in the class. My code is this:
class example:
def __init__(self):
self.points = 0
def operations(self):
def add(self):
self.points += 1
def subtract(self):
self.points -= 1
def display(self):
print(self.points)
obj = example()
obj.display()
obj.operations.add()
I get the output 0 and then get the error:
obj.operations.add()
AttributeError: 'function' object has no attribute 'add'
I have tried many other ways to solve this but none have worked. Please answer if you know how to fix this error.
-Thanks