listing the lliststack py module implementation of the stack adt using singly linked list class stack creates an empty stack def __init__self )self _top none self _size returns true if the stack is empty or false otherwise def isemptyself )return self _top is none returns the number of items in the stack def __len__self )return self _size returns the top item on the stack without removing it def peekself )assert not self isempty()"cannot peek at an empty stackreturn self _top item removes and returns the top item on the stack def popself )assert not self isempty()"cannot pop from an empty stacknode self _top self top self _top next self _size - return node item pushes an item onto the top of the stack def pushselfitem self _top _stacknodeitemself _top self _size + the private storage class for creating stack nodes class _stacknode def __init__selfitemlink self item item self next link the class constructor creates two instance variables for each stack the top field is the head reference for maintaining the linked list while size is an integer value for keeping track of the number of items on the stack the latter has to be adjusted when items are pushed onto or popped off the stack figure on the next page illustrates sample stack object for the stack from figure (bthe stacknode class is used to create the linked list nodes note the inclusion of the link argument in the constructorwhich is used to initialize the next field of the new node by including this argumentwe can simplify the prepend operation of the push(method the two steps required to prepend node to linked list are combined by passing the head reference top as the second argument of the stacknode(constructor and assigning reference to the new node back to top