(self, data)
| 8 | self.top = None |
| 9 | |
| 10 | def push(self, data): |
| 11 | print(f"Adding {data} to the top of the stack") |
| 12 | |
| 13 | # If there is no data, we add the value in the top element and return |
| 14 | if self.top == None: |
| 15 | self.top = Node(data) |
| 16 | return |
| 17 | new_node = Node(data) |
| 18 | new_node.next = self.top |
| 19 | self.top = new_node |
| 20 | |
| 21 | def pop(self): |
| 22 | # If there is no data in the top node, we return |