Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class stack:
- def __init__(self):
- self.tab = []
- def isempty(self):
- return len(self.tab) == 0
- def push(self,value):
- self.tab.append(value)
- def pop(self):
- if self.isempty():
- print("The stack is empty")
- else :
- x= self.tab.pop()
- return x
- def peek(self):
- if self.isempty():
- print("The stack is empty")
- else :
- return self.tab[-1]
- def __str__(self):
- return str(self.tab)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement