# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
class Node:

    def __init__(self, data):
        self.data = data
        self.next = None

class Stack:

    def __init__(self):
        self.__head = None
        self.__count = 0

    def push(self, element):

        node = Node(element)
        node.next = self.__head
        self.__head = node
        self.__count += 1

    def pop(self):

        if self.isEmpty():
            print("Hey Stack is empty")
            return
        data = self.__head.data
        self.__head = self.__head.next
        self.__count -= 1
        return data

    def top(self):
        if self.isEmpty():
            print("Hey Stack is empty")
            return
        data = self.__head.data
        return data

    def isEmpty(self):
        return self.size() == 0

    def size(self):
        return self.__count


# + pycharm={"name": "#%%\n"}
s = Stack()
s.push(12)
s.push(100)
s.push(13)
x = s.top()
print(x)
s.size()
s.pop()
s.size()
s.top()
s.pop()
s.pop()
s.pop()

StarcoderdataJupyterScriptsDedupFiltered