Advertisement
Falexom

Untitled

Jul 1st, 2023
961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. class Stack:
  2.     def __init__(self, stack):
  3.         self.__stack = stack
  4.  
  5.     def push(self, value):
  6.         self.__stack.append(value)
  7.  
  8.     def pop(self):
  9.         self.__stack.pop()
  10.  
  11.     def clear(self):
  12.         for element in range(len(self.__stack)):
  13.             self.__stack.pop()
  14.  
  15.     def view(self):
  16.         print(self.__stack)
  17.  
  18.  
  19. s = Stack([1])
  20. s.push(5)
  21. s.push(3)
  22. s.push(4)
  23. s.push(8)
  24. s.push(9)
  25. s.view()
  26. s.pop()
  27. s.pop()
  28. s.view()
  29. s.clear()
  30. s.view()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement