products=[["iphone",6888],["MacPro",14800],["Nova 10",2699],["Coffee",31],["Book",60],["Nike",699]]
str="商品列表"
yue=0
gouwuche=[]
print(f"{str:-^32}")
for a,b in enumerate(products):
print(f"{a:<10}{b[0]:<20}{b[1]}")
yusuan=int(input("请输入你的预算:"))
while True:
bianhao=input("请输入您想购买的产品编号")
if bianhao == "q":
print(gouwuche)
break
list = products[int(bianhao)]
gouwuche.append(list[0])
yusuan =yusuan-list[1]
print(f"已将{list[0]}放入购物车")
if yusuan<0:
print("余额不足")
yusuan =yusuan+list[1]
del gouwuche[-1]
print(gouwuche)
break
06-18
1668
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)