Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Node:
- def __init__(self, value):
- self.val = value
- self.next = None
- class Stack:
- def __init__(self):
- self.head = None
- def push(self, el):
- if self.head == None:
- self.head = Node(el)
- else:
- tmp = Node(el)
- tmp.next = self.head
- self.head = tmp
- def pop(self):
- self.head = self.head.next
- def print(self):
- tmp = self.head
- while tmp is not None:
- print(tmp.val,end='\n')
- tmp = tmp.next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement