MCPcopy
hub / github.com/TheAlgorithms/Python / is_empty

Method is_empty

data_structures/stacks/stack.py:95–108  ·  view source on GitHub ↗

Check if a stack is empty. >>> S = Stack() >>> S.is_empty() True >>> S = Stack() >>> S.push(10) >>> S.is_empty() False

(self)

Source from the content-addressed store, hash-verified

93 return self.stack[-1]
94
95 def is_empty(self) -> bool:
96 """
97 Check if a stack is empty.
98
99 >>> S = Stack()
100 >>> S.is_empty()
101 True
102
103 >>> S = Stack()
104 >>> S.push(10)
105 >>> S.is_empty()
106 False
107 """
108 return not bool(self.stack)
109
110 def is_full(self) -> bool:
111 """

Callers 3

infix_to_postfixFunction · 0.95
test_stackFunction · 0.95
balanced_parenthesesFunction · 0.95

Calls

no outgoing calls

Tested by 1

test_stackFunction · 0.76