stack in python

>>> from collections import deque
>>> myStack = deque()
>>> myStack.append('a')
>>> myStack.append('b')
>>> myStack.append('c')
>>> myStack
deque(['a', 'b', 'c'])
>>> myStack.pop()
'c'
>>> myStack
deque(['a', 'b'])

Here is what the above code is Doing:
1. Create a deque object.
2. Append ‘a’ to the deque.
3. Append ‘b’ to the deque.
4. Append ‘c’ to the deque.
5. Print the deque.
6. Pop the last element from the deque.
7. Print the deque.

As you can see, the deque works like a stack.

Now, let’s see how to use a deque as a queue.