Created
December 22, 2018 17:26
-
-
Save cemdrk/0782ce013f0f7c2cacbf2c234af4cd18 to your computer and use it in GitHub Desktop.
stack implementation python
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 get_stack(self): | |
return self.items | |
def is_empty(self): | |
return self.items == [] | |
def peek(self): | |
if not self.is_empty(): | |
return self.items[-1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment