products = [['iphone', 6888], ['MacPro', 14800], ['小米6', 2499], ['Coffee', 31], ['Book', 60], ['Nike', 600]]
print('-'*6+'商品列表'+'-'*6)
i = 0
for product in products:
print(i, end='t')
for detail in product:
print(detail, end='t')
print('n')
i += 1
shopping_list = []
while True:
respond = input('请选择您要购买的商品号码:(如需退出请输入‘q’)')
if respond == 'q':
break
shopping_list.append(products[int(respond)])
print('-'*30)
print('您的商品清单是:')
n = 1
for goods in shopping_list:
print(n, end='t')
for detail in goods:
print(detail, end='t')
n += 1
print('n')
cost = 0
for value in shopping_list:
cost += int(value[1])
print('总计:%d'%cost)
运行结果:
没有添加中断代码,可自行补充。



