Use List as a stack: push and pop : Stack « Data Structure « Python






Use List as a stack: push and pop

Use List as a stack: push and pop

L = []
L.append(1)                    # push onto stack
L.append(2)
print L

L.pop()                        # pop off stack
print L


           
       








Related examples in the same category

1.Use list as a stack: push onto stackUse list as a stack: push onto stack