1.代码 1.1 增 1.2 删 1.3 改 1.4 查
1.5 列表的各种操作 1.6 列表的嵌套打印方法: 1.7 分配老师: 1.8 作业
products=[["iphone",6888],["MacPro",14800],["小米6",2499],["iPad",3999],
["coffee",31],["book",60],["Nike",699],["李宁男鞋",229]]
buy=[]
print("-"*30+"商品列表"+"-"*30)
number=0
for i in products:
number=number+1
print(number,end='\t')
for j in i:
print(j,end='\t')
print()
i=0
while i==0:
num=input("请输入你想购买的商品:")
if num=='q':
break
nums=int(num)
buy.append(products[nums-1])
print("-"*30+"购物列表"+"-"*30)
number=0
for i in buy:
number=number+1
print(number,end='\t')
for j in i:
print(j,end='\t')
print()
|