返回顶部

收藏

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

»更多 您可能感兴趣的代码
  1. 2016-03-08 09:08:58Assign list to a list item by 张宋付
  2. 2016-04-23 10:16:24Concatenation ( + ) by 蟋蟀MM
  3. 2016-05-29 21:12:40List repetition by Solon.Ring
  4. 2016-08-18 13:26:40List slicing by xwz
  5. 2016-09-02 18:27:52Class inside a List by wubai
  6. 2016-09-19 09:12:04List: assign by index by wubai
  7. 2016-12-04 17:38:14List sort() Demo by 张宋付
  8. 2017-03-06 12:36:51Lists can be written as a list of comma-separated values (items) between square brackets. by 阿明娃儿
  9. 2014-05-11 09:36:14python 中如何判断list中是否包含某个元素 by 玉开Sir
  10. 2016-04-23 10:37:45List membership demo by 山药
  11. 2016-05-29 21:23:15A list of lists: nested list by Solon.Ring

发表评论