From cad17f857cdaacbb39c4dee79124c83652f8ef2d Mon Sep 17 00:00:00 2001 From: Shaunak Chadha Date: Sun, 1 Oct 2017 15:39:26 +0530 Subject: [PATCH] Create stack.py --- Python implementation DataStructures/stack.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Python implementation DataStructures/stack.py 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())