From bb366686c1a329ae940f6097d85c3c107bba781e Mon Sep 17 00:00:00 2001 From: Benjamin Adovasio Date: Sun, 15 Mar 2026 16:28:03 -0400 Subject: [PATCH] added __len__ --- Project 5/Stack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project 5/Stack.py b/Project 5/Stack.py index 4371bdd..496dfc0 100644 --- a/Project 5/Stack.py +++ b/Project 5/Stack.py @@ -21,7 +21,7 @@ class Stack[T]: ''' initializes an empty stack ''' self._data = LinkedList() - + def __len__(self) -> int: ''' allows the len function to be called using an ArrayStack object, e.g., stack = ArrayStack() @@ -29,7 +29,7 @@ class Stack[T]: Returns: number of elements in the stack, as an integer ''' - pass + return len(self._data) def push(self, item: T) -> None: ''' pushes a given item of arbitrary type onto the stack