First of all, we need to initial a new stack. In other word, we need to create a new empty list.
Secondly, we can push any element into the stack through using a list method, list.append().
Finally, if we need to delete the top element from stack, we can achieve by using list.pop() method.
By and large, any elements push into the stack will be on the top of the stack, which will be removed firstly as well. What's more, all of the operation can be achieved by two list method, list.pop() and list.append().



没有评论:
发表评论