python list shift left

Solutions on MaxInterview for python list shift left by the best coders in the world

showing results for - "python list shift left"
Paulina
06 Apr 2017
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