Stack is a linear data structure that allows operations at one end which can be called top of the stack. We can add elements or remove elements from this end of the stack only.
In a stack the element inserted last in sequence will come out first as we can remove only from the top of the stack. Such feature is known as Last in First Out(LIFO) feature. The operations of adding and removing the elements is known as PUSH and POP. In the following program we implement it as add and remove functions. We declare an empty list and use the in-built append() and pop() methods of ‘list’ datatype of python to add and remove the data elements.