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

AttributeError: Got AttributeError when attempting to get a value for field `abc` on serializer `PfleSerializer`. The serializer field might be named incorrectly and not match any attribute or key on the `QuerySet` instance. Original exception text was: 'QuerySet' object has no attribute 'abc'.

ImportError: No module named regex