Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. class Node:
  2. def __init__(self, value):
  3. self.val = value
  4. self.next = None
  5. class Stack:
  6. def __init__(self):
  7. self.head = None
  8. def push(self, el):
  9. if self.head == None:
  10. self.head = Node(el)
  11. else:
  12. tmp = Node(el)
  13. tmp.next = self.head
  14. self.head = tmp
  15. def pop(self):
  16. self.head = self.head.next
  17.  
  18. def print(self):
  19. tmp = self.head
  20. while tmp is not None:
  21. print(tmp.val,end='\n')
  22. tmp = tmp.next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement