Python 序列操作

练习List的使用。。有点旧,不过复习下,很多都掌握不牢固。。。

#!/usr/bin/python

shoplist=['apple','jack','banane']
print 'shoplist have',
for i in shoplist:
    print i,
print '\ni buy the shop:kate'
shoplist.append('kate')
print '\nthe shoplist have:',
for i in shoplist:
    print i,
print '\nWe can del the Only One apple'
del shoplist[0]
print '\nthen the shoplist have',
for i in shoplist:
    print i,
print 'We can sort the list'
shoplist.sort()
print 'shoplist:',shoplist

 

posted @ 2013-03-05 12:59  墨迹哥's  阅读(179)  评论(0编辑  收藏  举报