Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stack:
- def __init__(self,size = 100):
- #@param self: int
- self.stack = []
- self.size = size
- def push(self,element):
- #@param element: qualsiasi tipo
- if len(self.stack)<=self.size:
- self.stack.append(element)
- else:
- print('Raggiunto limite di memoria')
- def pop(self):
- self.stack = self.stack[:-1]
- def top(self):
- #@return: qualsiasi tipo
- if self.stack != []:
- return self.stack[-1]
- def empty(self):
- #@return: bool
- return not self.stack
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement