Created
May 2, 2015 05:04
-
-
Save rehrumesh/5d2621e22deb08207ca1 to your computer and use it in GitHub Desktop.
Simple Python stack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stack: | |
def __init__(self): | |
self.items=[] | |
def isEmpty(self): | |
return self.items==[] | |
def push(self,item): | |
self.items.append(item) | |
def pop(self): | |
return self.items.pop() if not self.isEmpty() else None | |
def peek(self): | |
return self.items[len(self.items) - 1] if not self.isEmpty() else None | |
def size(self): | |
return len(self.items) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment