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:
def __init__(self):
self = []
def isEmpty(self):
return self == []
def push(self, item):
self.append(item)
def pop(self):
return self.pop(0)
def size(self):
return len(self)
s = myStack()
s.push('1')
s.push('2')
print(s.pop())
print s
Your stack is an array...
Implementing a Stack in Python from the book of Problem Solving with Algorithms and Data Structures
Below is my implementation
Below is the simple implementation of stack in python. In addition, it returns the middle element at any point in time.
Output: