Last active
March 20, 2021 09:20
-
-
Save Kimxons/dd343363e074915dab2399bc11df57b2 to your computer and use it in GitHub Desktop.
Working with stack in python 3
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
| #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