In [11]:
def isStackEmpty(top):
    return top == -1

def push(S, top, x):
    top = top + 1
    S.append(x)
    
def pop(S, top):
    if isStackEmpty(top):
        return "error"
    top = top - 1
    return S[top + 1]

In [13]:
S = []

print(isStackEmpty(top))
push(S, top, 1)
push(S, top, 2)
print(isStackEmpty(top))
print(pop(S, top))
print(pop(S, top))
print(pop(S, top))


True
True
error
error
error

In [ ]: