Created
March 6, 2019 02:45
-
-
Save DustinAlandzes/f83527282e6b1af585eb3900d85b46e0 to your computer and use it in GitHub Desktop.
a Stack class using Python lists: http://interactivepython.org/runestone/static/pythonds/BasicDS/ImplementingaStackinPython.html
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.items = [] | |
def isEmpty(self): | |
return self.items == [] | |
def push(self, item): | |
self.items.append(item) | |
def pop(self): | |
return self.items.pop() | |
def peek(self): | |
return self.items[len(self.items)-1] | |
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