#!/usr/bin/python3
# ==================================================================
# From: www.youtube.com/watch?v=IVFnq4zbs-g
# ==================================================================
"""
Stack Data Structure
push - put an item on the top of the stack
pop - remove (return) the top item of the stack
"""
class Stack():
def __init__(self):
self.items = []
def push(self,item):
self.items.append(item)
def pop(self):
return self.items.pop()
def is_empty(self):
return self.items == []
def peek(self):
if not self.is_empty():
return self.items[-1]
else:
return None
def get_stack(self):
return self.items
# ---- main --------------------------------------------------------
s = Stack()
print(s.peek())
s.push("A")
s.push("B")
print(s.peek())
print(s.get_stack()) ## display the stack (list)