-2

I am learning data structures and am currently working on stacks. I was wondering how you determine if the stack is empty?

from copy import deepcopy

class Stack:

    def __init__(self):
        """
        -------------------------------------------------------
        Initializes an is_empty stack. Data is stored in a Python list.
        Use: s = Stack()
        -------------------------------------------------------
        Returns:
            a new Stack object (Stack)
        -------------------------------------------------------
        """
        self._values = []

    def is_empty(self):
        """
        -------------------------------------------------------
        Determines if the stack is empty.
        Use: b = s.is_empty()
        -------------------------------------------------------
        Returns:
            True if the stack is empty, False otherwise
        -------------------------------------------------------
        """

        # Your code here
khelwood
  • 52,115
  • 13
  • 74
  • 94
A.Riaz
  • 7
  • 1

1 Answers1

0

If self._values is an empty list, the stack is empty

radrow
  • 5,532
  • 3
  • 25
  • 45