asset_all = eval(input(“请输入总资产:”))
car_list = []
goods = [
    {“name”:”电脑”,”price”: 1999},
    {“name”:”鼠标”,”price”: 10},
    {“name”:”游艇”,”price”: 20},
    {“name”:”美女”,”price”: 998},
    ]
for i in goods:
    print(i[\’name\’],i[\’price\’])
while True:
    i2 = input(“请输入商品(y/Y进行结算):”)
    if i2.lower() == \’y\’:
        break
    for j in goods:
        if j[\’name\’] ==i2:
            car_list.append(j)
print(car_list)
sum = 0
for item in car_list:
    p = item[\’price\’]
    sum += p
print(asset_all,sum)
if asset_all < sum:
    print(“余额不足”)
else:
    print(“购买成功”)

版权声明:本文为wssaried原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/wssaried/p/9862693.html