Created
July 9, 2016 10:54
-
-
Save sumedhe/b637b62795dc50cb7b63f71dfd75ac40 to your computer and use it in GitHub Desktop.
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 push(self, item): | |
| self.items.append(item) | |
| def pop(self): | |
| return self.items.pop() | |
| def peek(self): | |
| return self.items[0] | |
| def isEmpty(self): | |
| return len(self.items) == 0 | |
| ## example code | |
| def test(): | |
| s = Stack() | |
| s.push(10) | |
| s.push(20) | |
| s.push(30) | |
| print(s.items) | |
| print(s.pop()) | |
| print(s.items) | |
| print(s.isEmpty()) | |
| #test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment