Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stack:
- def __init__(self, Size):
- self.Stack = [None]*Size
- self.Ind = -1
- def Push(self, Val):
- self.Ind += 1
- self.Stack[self.Ind] = Val
- def Pop(self):
- self.Stack[self.Ind] = None
- self.Ind -= 1
- def Peek(self):
- return self.Stack[self.Ind]
- def isEmpty(self):
- return self.Ind == -1
- StackObj = Stack(5)
- StackObj.Push(10)
- StackObj.Push(12)
- StackObj.Push(16)
- print(StackObj.Peek())
- StackObj.Pop()
- print(StackObj.Peek())
- StackObj.isEmpty()
- print(StackObj.Stack)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement