I am trying to create a simple class that inputs a list then appends to the list with a function called "add" which is also defined in the same class.
I keep getting this error: 'list' object has no attribute 'a'
class try1:
def __init__(self, a=[]):
self.a = a
print(a)
return
def add(self, b=None):
self.a.append(b)
print(a)
return
if __name__ == "__main__":
c=try1(['a', 'b', 'c'])
d = ['d', 'e', 'f']
try1.add(d)