Skip to content

Commit

Permalink
Create stack.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrow1997 authored Oct 1, 2017
1 parent 04673ae commit cad17f8
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 cad17f8

Please sign in to comment.