python list

shoplist=['apple','mango','carrot','banana']
print('i have',len(shoplist),'items to purchase.')
print('These items are:')
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)

 

posted @ 2013-09-17 09:55  yufenghou  阅读(130)  评论(0)    收藏  举报