- #!/usr/bin/python
- #2011/09/16 by larry
- import sys
- shoplist=['apple','banana','mango','carrot']
- buylist=[]
- print 'These item are:'
- for item in shoplist:
- print item
- while True:
- call=raw_input("choose you want to buy:")
- if call=='quit':break
- else:
- if call not in shoplist:
- print 'shoplist is not your choose!!'
- pass
- else:
- shoplist.remove(call)
- buylist.append(call)
- if len(shoplist)==0:break
- if len(shoplist)==0:print 'the shoplist is empty!'
- else:
- print 'the rest of shoplist as follows:'
- for rest in shoplist:print rest,
- if len(buylist)==0:
- print 'your buylist is empty!'
- else:
- print 'your buylist have:'
- for buy in buylist:
- print buy,
转载于:https://blog.51cto.com/5iqiong/665789