Abstract Data Type: Stack

Python

class Stack:

    def __init__(self):
        self.data = []

    def push(self, element):
        self.data.append(element)

    def peek(self):
        return self.data[-1]

    def pop(self):
        return self.data.pop()


stack = Stack()
stack.push(1)
assert stack.peek() == 1

stack.push(5)
assert stack.peek() == 5
assert len(stack.data) == 2

assert stack.pop() == 5
assert len(stack.data) == 1