DATABRICKS LEARNING

DAY 1 Video : Introduction

# We will implement Stack operations using List
# Last in First Out

class MyStack:
def __init__(self):
self.mystack = []

def add_stack(self,val):
#adding member
self.mystack.append(val)

def remove_stack(self):
#remove from the list
self.mystack.pop()

def print_stack(self):
print(“Values in the list are: \n,self.mystack)

stack1 = MyStack()
stack1.add_stack(40)
stack1.add_stack(10)
stack1.add_stack(30)
stack1.add_stack(60)
stack1.add_stack(20)
stack1.print_stack()
stack1.remove_stack()
stack1.print_stack()
stack1.remove_stack()
stack1.print_stack()