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
原文地址:https://www.cnblogs.com/xiaoCon/p/2944135.html