this is the code:
class Empty(Exception):
pass
class ArrayStack:
def __init__(self):
self._data = []
def __len(self):
return len(self._data)
def is_empty(self):
return len(self._data)==0
def push(self, e):
self._data.append(e)
def pop(self):
if self.is_empty():
raise empty('Stack is Empty')
return self._data.pop()
def top(self):
if self.is_empty():
raise empty('Stack is Empty')
return self._data[-1]
s= ArrayStack()
s.push(10)
s.push(20)
print('Stack: ', s._data)
**print('Length: ', len(s)) #this line is throwing the problem**
print('Is-Empty: ', s.is_empty())
print('Popped: ', s.pop())
print('Stack: ', s._data)
error message
Traceback (most recent call last): File "main.py", line 31, in print('Length: ', s.__len()) AttributeError: 'ArrayStack' object has no attribute '__len'