Skip to content

Instantly share code, notes, and snippets.

@LucasMagnum
Created September 7, 2018 09:54
Show Gist options
  • Save LucasMagnum/a4b2131322c4fbe7d93b952ea34c2b52 to your computer and use it in GitHub Desktop.
Save LucasMagnum/a4b2131322c4fbe7d93b952ea34c2b52 to your computer and use it in GitHub Desktop.
class Stack:
def __init__(self):
self.items = []
def push(self, value):
self.items.append(value)
def pop(self):
return self.items.pop()
def isEmpty(self):
return len(self.items) == 0
def top(self):
return self.items[-1]
if __name__ == '__main__':
stack = Stack()
stack.push(1)
stack.pop()
stack.push(2)
stack.push(3)
stack.push(4)
stack.push(5)
while not stack.isEmpty():
print(stack.pop())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment