diff --git a/Python implementation DataStructures/stack.py b/Python implementation DataStructures/stack.py new file mode 100644 index 00000000..8542adf9 --- /dev/null +++ b/Python implementation DataStructures/stack.py @@ -0,0 +1,28 @@ + +#Make a class Stack +class Stack: + def __init__(self): + self.items = [] + + def isEmpty(self): + return self.items == [] + + def push(self, item): + self.items.insert(0,item) + + def pop(self): + return self.items.pop(0) + + def peek(self): + return self.items[0] + + def size(self): + return len(self.items) + + #Calling Object of class Stack + s = Stack() + + #Calling the function + s.push('hello') + s.push('true') + print(s.pop())