Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stack:
- class StackNode:
- def __init__(self, value):
- self.value = value
- self.next = None
- def __init__(self):
- self.head = None
- def add(self, value):
- if self.head is None:
- self.head = self.StackNode(value)
- return
- current = self.head
- while current.next is not None:
- current = current.next
- current.next = self.StackNode(value)
- def remove(self, value):
- if self.head is None:
- return
- self.head = self.head.next
- def peek(self):
- return self.head
- def is_empty(self):
- return self.head is None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement