Write a class to implement stack in python (dynamic).


In [1]:
class stack(object):
    '''Class to implement stack data structure with the following methods:
        -push(element)
        -pop()'''
    def __init__(self):
        self.s = []
    def push(self,elem):
        self.s.append(elem)
    def pop(self):
        p =  self.s[-1]
        del self.s[-1]
        return p

In [ ]: