#!/usr/bin/python
#coding:utf-8 ten_things = "apples oranges crows telephone light sugar"
print "wait there's not 10 things in that list,let's fix that" stuff = ten_things.split(' ') #10个东西,以' '间隔开
more_stuff = ["day","night","song","frisbee","corn","banana","girl","boy"] #更多的原料 while len(stuff) != 10: #取得List stuff的长度,当不等于10时循环
next_one = more_stuff.pop() #截取more_stuff的最后一个元素(默认值)
print "adding:",next_one #输出pop取得的值
stuff.append(next_one) #使用append将之前截取的值赋予list:stuff
print "there's %d items now" % len(stuff) print "there we go : ",stuff print "let's do some things with stuff" print stuff[1] #第二个元素,list从0计数
print stuff[-1] #whoa!fancy 最后一个元素(-1)
print stuff.pop()
print ' '.join(stuff) #what?cool!
print '#'.join(stuff[3:5]) # super stellar

Output:

 wait there's not 10 things in that list,let's fix that
adding: boy
there's 7 items now
adding: girl
there's 8 items now
adding: banana
there's 9 items now
adding: corn
there's 10 items now
there we go : ['apples', 'oranges', 'crows', 'telephone', 'light', 'sugar', 'boy', 'girl', 'banana', 'corn']
let's do some things with stuff
oranges
corn
corn
apples oranges crows telephone light sugar boy girl banana
telephone#light

join()

加分题的一些参考: Python 面向对象编程 函数式编程

最新文章

  1. Centos7 wifi
  2. MYSQL开启慢查询日志实施
  3. ngui中 代码调用按钮事件(后来改成了按钮绑定键盘..)
  4. window.location.href url含中文服务器收到乱码问题解决
  5. 一步一步搭建客服系统 (2) 如何搭建SimpleWebRTC信令服务器
  6. OpenXml入门----给Word文档添加表格
  7. depth_write
  8. 让qq图标在自己的网站上显示方法
  9. C++编程规范之23:头文件应该自给自足
  10. HDU 1398 Square Coins
  11. 高效程序猿之 VS2010快速生成代码模板
  12. Oracle数据泵(上)
  13. Codeforces Round #300(Div. 2)-538A.str.substr 538B.不会 538C.不会 。。。
  14. Centos中安装gitlab
  15. [转]TopShelf 用法
  16. Python 高度定制化自己的线程类和进程类代码,获取启动进程或线程方法的结果(兼容Py2和Py3)
  17. mysql 开发基础系列16 视图
  18. iOS开发简记(8):数据持久化
  19. 研究一下Spark Hash Shuffle 和 SortShuffle 原理机制
  20. SpringBoot的json序列化及时间序列化处理

热门文章

  1. ARM汇编2
  2. Codeforces 475D 题解(二分查找+ST表)
  3. 扩展欧几里得算法详解(exgcd)
  4. SpringMVC Controller单例和多例(转)
  5. python学习第四十九天XML模块的用法
  6. Python 函数知识总汇
  7. 基于 Python 的自定义分页组件
  8. wxpython程序基本功能源码整理,包括基本文字,输入框,字体设置,按钮绑定事件触发
  9. EF添加关联的提示问题:映射从第 260 行开始的片段时有问题:
  10. PhotonServer新增应用的配置