返回顶部

收藏

Using Lists as Stacks

更多
#To add an item to the top of the stack, use append(). To retrieve an item from 
#the top of the stack, use pop() without an explicit index.

stack = [3, 4, 5]
stack.append(6)
stack.append(7)
print stack

stack.pop()

print stack

print stack.pop()

print stack.pop()

print stack

标签:Python,List

收藏

0人收藏

支持

0

反对

0

发表评论