stacks illustrates new values being added to the top of the stack and one value being removed from the top define stack adt stack is data structure that stores linear collection of items with access limited to last-in first-out order adding and removing items is restricted to one end known as the top of the stack an empty stack is one containing no items stack()creates new empty stack isempty()returns boolean value indicating if the stack is empty length ()returns the number of items in the stack pop()removes and returns the top item of the stackif the stack is not empty items cannot be popped from an empty stack the next item on the stack becomes the new top item peek()returns reference to the item on top of non-empty stack without removing it peekingwhich cannot be done on an empty stackdoes not modify the stack contents pushitem )adds the given item to the top of the stack to illustrate simple use of the stack adtwe apply it to the problem of reversing list of integer values the values will be extracted from the user until negative value is enteredwhich flags the end of the collection the values will then be printed in reverse order from how they were entered we could use simple list for this problembut stack is ideal since the values can be pushed onto the stack as they are entered and then popped one at time to print them in reverse order solution for this problem follows prompt "enter an int value (< to end):mystack stack(value int(inputprompt )while value > mystack pushvalue value int(inputprompt )while not mystack isempty(value mystack pop(printvalue suppose the user enters the following valuesone at time -