#!/usr/bin/python
# Filename: using_list.py
# This is my shopping list
shoplist = ['apple', 'mango', 'carrot', 'banana'] # 新建列表
print 'I have', len(shoplist),'items to purchase.'
print 'These items are:', # Notice the comma at end of the line
for item in shoplist: # 展示列表
print item,
print '\nI also have to buy rice.'
shoplist.append('rice') # 往列表添加元素
print 'My shopping list is now', shoplist
print 'I will sort my list now'
shoplist.sort() # 按序排列列表
print 'Sorted shopping list is', shoplist
print 'The first item I will buy is', shoplist[0]
olditem = shoplist[0]
del shoplist[0] # 删除列表元素
print 'I bought the', olditem
print 'My shopping list is now', shoplist