边看边写做出来的,自己想真滴莫得什么思路
products = [["iphone", 6888], ["MacPro", 14800], ["小米6", 2499], ["Coffee", 31], ["Book", 60], ["Nike", 699]]
money=0
names=[]
while True:
print("-"*6,"商品价格","-"*6)
for i,name in enumerate(products): #使用枚举同时拿到下标与元素
print(i+1,name[0],name[1])
a=input("请输入编号(q结算):")
if a=="q":
print("您买了%s:总价为:%d元"%(names,money))
break
***b=int(a)-1
c=products[b]
names.append(c[0])
money+=c[1]***