Submitted by prashant_agr on Sun, 2007-05-06 14:47.
his is very easy implementation of LIFO stack.
>> stack = [1, 2, 3]
>>> stack.append(4)
>>> stack.append(5)
>>> stack
[1, 2, 3, 4]
>>> stack.pop()
7
Pop takes the last argument that is on the stack.
Re: How to use list in Python as stack?
his is very easy implementation of LIFO stack.
>> stack = [1, 2, 3]
>>> stack.append(4)
>>> stack.append(5)
>>> stack
[1, 2, 3, 4]
>>> stack.pop()
7
Pop takes the last argument that is on the stack.