So for learning python and just in general some data structures, I am creating a Stack to start with. This is a simple array-based stack.
Here is my code:
class ArrayBasedStack:
'Class for an array-based stack implementation'
def __init__(self):
self.stackArray = []
def pop():
if not isEmpty():
# pop the stack array at the end
obj = self.stackArray.pop()
return obj
else:
print('Stack is empty!')
return None
def push(object):
# push to stack array
self.stackArray.append(object)
def isEmpty():
if not self.stackArray: return True
else: return False
'''
Testing the array-based stack
'''
abs = ArrayBasedStack()
abs.push('HI')
print(abs.pop())
But I'm getting this error:
Traceback (most recent call last):
File "mypath/arrayStack.py", line 29, in abs.push('HI')
TypeError: push() takes 1 positional argument but 2 were given [Finished in 0.092s]