Skip to content

Instantly share code, notes, and snippets.

@cemdrk
Created December 22, 2018 17:26
Show Gist options
  • Save cemdrk/0782ce013f0f7c2cacbf2c234af4cd18 to your computer and use it in GitHub Desktop.
Save cemdrk/0782ce013f0f7c2cacbf2c234af4cd18 to your computer and use it in GitHub Desktop.
stack implementation python
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