MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / peek

Method peek

data_structures/stacks/stack.py:38–41  ·  view source on GitHub ↗

Peek at the top-most element of the stack.

(self)

Source from the content-addressed store, hash-verified

36 raise IndexError('pop from an empty stack')
37
38 def peek(self):
39 """ Peek at the top-most element of the stack."""
40 if self.stack:
41 return self.stack[-1]
42
43 def is_empty(self):
44 """ Check if a stack is empty."""

Callers 2

infix_to_postfixFunction · 0.95
stack.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected