working with deques deque is simply queue where you can remove and add items from either end in many languagesa queue or stack starts out as deque specialized code serves to limit deque functionality to what is needed to perform particular task when working with dequeyou need to think of the deque as sort of horizontal line certain individual functions work with the left and right ends of the deque so that you can add and remove items from either side the following steps help you create an example that demonstrates deque usage this example also appears with the downloadable source code as dequedata py open python file window you see an editor in which you can type the example code type the following code into the window -pressing enter after each line import collections mydeque collections deque("abcdef" print("starting state:"for item in mydequeprint(itemend="print("\ \ \ \nappending and extending right"mydeque append(" "mydeque extend("ij"for item in mydequeprint(itemend="print("\ \nmydeque contains { items format(len(mydeque))print("\ \npopping right"print("popping { }format(mydeque pop())for item in mydequeprint(itemend="print("\ \ \ \nappending and extending left"mydeque appendleft(" "mydeque extendleft("bc"for item in mydequeprint(itemend="print("\ \nmydeque contains { items format(len(mydeque))