simple array-based stack implementation we can implement stack quite easily by storing its elements in python list the list class already supports adding an element to the end with the append methodand removing the last element with the pop methodso it is natural to align the top of the stack at the end of the listas shown in figure top figure implementing stack with python liststoring the top element in the rightmost cell although programmer could directly use the list class in place of formal stack classlists also include behaviors ( adding or removing elements from arbitrary positionsthat would break the abstraction that the stack adt represents alsothe terminology used by the list class does not precisely align with traditional nomenclature for stack adtin particular the distinction between append and push insteadwe demonstrate how to use list for internal storage while providing public interface consistent with stack the adapter pattern the adapter design pattern applies to any context where we effectively want to modify an existing class so that its methods match those of relatedbut differentclass or interface one general way to apply the adapter pattern is to define new class in such way that it contains an instance of the existing class as hidden fieldand then to implement each method of the new class using methods of this hidden instance variable by applying the adapter pattern in this waywe have created new class that performs some of the same functions as an existing classbut repackaged in more convenient way in the context of the stack adtwe can adapt python' list class using the correspondences shown in table stack method push(es pops tops is emptylen(srealization with python list append(el popl[- len( = len(ltable realization of stack as an adaptation of python list