Skip to content

Instantly share code, notes, and snippets.

@Kimxons
Last active March 20, 2021 09:20
Show Gist options
  • Save Kimxons/dd343363e074915dab2399bc11df57b2 to your computer and use it in GitHub Desktop.
Save Kimxons/dd343363e074915dab2399bc11df57b2 to your computer and use it in GitHub Desktop.
Working with stack in python 3
#implementation one
stack = [2,3,4]
stack.append(7)
print("Stack after appending: \n", stack)
stack.pop()
print("Stack after popping: \n", stack)
#implementation two
class Stack:
def __init__(self):
self.stack = []
def isEmpty(self):
return len(self.stack) == 0
def push(self,p):
self.stack.append(p)
def pop(self):
return self.stack.pop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment