1from collections import deque
2items = deque([1, 2])
3items.append(3) # deque == [1, 2, 3]
4items.rotate(1) # The deque is now: [3, 1, 2]
5items.rotate(-1) # Returns deque to original state: [1, 2, 3]
6item = items.popleft() # deque == [2, 3]
7