Skip to content

Instantly share code, notes, and snippets.

@dimejimudele
Last active January 30, 2019 16:33
Show Gist options
  • Save dimejimudele/099d0a7d639da9b03396fb2ba6738183 to your computer and use it in GitHub Desktop.
Save dimejimudele/099d0a7d639da9b03396fb2ba6738183 to your computer and use it in GitHub Desktop.
Algorithms and data structures created by dimejimudele - https://repl.it/@dimejimudele/Algorithms-and-data-structures
# Implementiog stacks data structure
class stack:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def push(self, item):
return self.items.append(item)
def peek(self):
return self.items[-1]
def size(self):
return len(self.items)
s = stack()
s.push(7)
s.push(8)
s.push(9)
s.push(10)
print(s.peek())
print(s.size())
print(s.isEmpty())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment