Skip to content

Instantly share code, notes, and snippets.

Created Dec 31, 2020
What would you like to do?
class Stack:
def __init__(self):
self.theItems = list()
def isEmpty(self):
return len(self) == 0
def __len__(self):
return len(self.theItems)
def pop(self):
assert not self.isEmpty()
return self.theItems.pop()
def push(self, item):
PROMPT = "Enter an int value : "
myStack = Stack()
value = int(input(PROMPT))
while value >= 0:
value = int(input(PROMPT))
while not myStack.isEmpty():
value = myStack.pop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment