Skip to content

Instantly share code, notes, and snippets.

@mahmoudhossam
Created August 20, 2012 07:30
Show Gist options
  • Save mahmoudhossam/3401859 to your computer and use it in GitHub Desktop.
Save mahmoudhossam/3401859 to your computer and use it in GitHub Desktop.
A naive stack implementation
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