Created
August 20, 2012 07:30
-
-
Save mahmoudhossam/3401859 to your computer and use it in GitHub Desktop.
A naive stack implementation
This file contains hidden or 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.values = [] | |
def push(self, x): | |
self.values.append(x) | |
def pop(self): | |
x = self.values[-1] | |
self.values.remove(x) | |
return x | |
def size(self): | |
return len(self.values) | |
def is_empty(self): | |
return self.size() == 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment