Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. class stack:
  2. def __init__(self):
  3. self.tab = []
  4. def isempty(self):
  5. return len(self.tab) == 0
  6. def push(self,value):
  7. self.tab.append(value)
  8. def pop(self):
  9. if self.isempty():
  10. print("The stack is empty")
  11. else :
  12. x= self.tab.pop()
  13. return x
  14. def peek(self):
  15. if self.isempty():
  16. print("The stack is empty")
  17. else :
  18. return self.tab[-1]
  19. def __str__(self):
  20. return str(self.tab)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement