Skip to content

Commit

Permalink
Merge pull request #42 from sparrow1997/patch-1
Browse files Browse the repository at this point in the history
Create stack.py #20
  • Loading branch information
srbcheema1 authored Oct 1, 2017
2 parents 04673ae + cad17f8 commit 13d82c9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Python implementation DataStructures/stack.py
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit 13d82c9

Please sign in to comment.