I am trying to implement a simple stack with Python using arrays. I was wondering if someone could let me know what\'s wrong with my code.
class myStack:
Your stack is an array...
class stacked(): # Nodes in the stack
def __init__(self,obj,next):
self.obj = obj
self.next = next
def getObj(self):
return(self.obj)
def getNext(self):
return(self.next)
class stack(): # The stack itself
def __init__(self):
self.top=None
def push(self,obj):
self.top = stacked(obj,self.top)
def pop(self):
if(self.top == None):
return(None)
r = self.top.getObj()
self.top = self.top.getNext()
return(r)