Use Python Lists as Stacks

>>> stack =[]
>>> stack.append(1)
>>> stack.append(2)
>>> stack.append(2)
>>> stack
[1, 2, 2]
>>> stack.append(3)
>>> stack
[1, 2, 2, 3]
>>> stack.pop()
3
>>> stack.pop()
2
>>> stack
[1, 2]
>>>



Comments

Popular posts from this blog

ImportError: No module named regex