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:
class Stack:
s =[]
def push(self, num):
self.s.append(num)
def pop(self):
if len(self.s) == 0: # erro if you pop an empty list
return -1
self.s.remove(self.s[-1])
def isEmpty(self):
if len(self.s) == 0:
return True
else:
return False
def display(self): # this is to display how a stack actually looks like
if self.isEmpty():
print("Stack is Empty")
for i in range(len(self.s)-1,-1,-1): # I haven't used reversed() since it will be obv
print(self.s[i])
obj = Stack()
obj.push(3)
print(obj.isEmpty())
obj.push(4)
obj.display()
print("----")
obj.pop()
obj.display()