1#using doubly linked list
2from collections import deque
3myStack = deque()
4
5myStack.append('a')
6myStack.append('b')
7myStack.append('c')
8
9myStack
10deque(['a', 'b', 'c'])
11
12myStack.pop()
13'c'
14myStack.pop()
15'b'
16myStack.pop()
17'a'
18
19myStack.pop()
20
21#Traceback (most recent call last):
22 #File "<console>", line 1, in <module>
23##IndexError: pop from an empty deque
1>>> from collections import deque
2>>> myStack = deque()
3>>> myStack.append('a')
4>>> myStack.append('b')
5>>> myStack.append('c')
6>>> myStack
7deque(['a', 'b', 'c'])
8>>> myStack.pop()
9'c'
10>>> myStack
11deque(['a', 'b'])
1stack = []
2# add element in the stack.
3stack.append('a')
4# delete in LIFO order.
5stack.pop()
1>>> myStack = []
2
3>>> myStack.append('a')
4>>> myStack.append('b')
5>>> myStack.append('c')
6
7>>> myStack
8['a', 'b', 'c']
9
10>>> myStack.pop()
11'c'
12>>> myStack.pop()
13'b'
14>>> myStack.pop()
15'a'
16
17>>> myStack.pop()
18Traceback (most recent call last):
19File "<console>", line 1, in <module>
20IndexError: pop from empty list