Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import maxsize
- def createstack():
- stack = []
- return stack
- def isEmpty(stack):
- return len(stack) == 0
- def push(stack, item):
- stack.append(item)
- print(item + " pushed to stack")
- def pop(stack):
- if (isEmpty(stack)):
- return str(-maxsize -1)
- return stack.pop()
- def peek(stack):
- if (isEmpty(stack)):
- return str(-maxsize -1)
- return stack[len(stack) - 1]
- stack = createstack()
- push(stack , str(10))
- push(stack , str(20))
- push(stack , str(30))
- print(pop(stack) + " popped from stack")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement