博客
关于我
12 购物车之一(用列表)
阅读量:798 次
发布时间:2023-04-16

本文共 546 字,大约阅读时间需要 1 分钟。

asset_all = eval(input("请输入总资产:"))car_list = []goods = [    {"name":"电脑","price": 1999},    {"name":"鼠标","price": 10},    {"name":"游艇","price": 20},    {"name":"美女","price": 998},]for i in goods:    print(f"{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 = 0for item in car_list:    p = item['price']    sum += pprint(asset_all, sum)if asset_all < sum:    print("余额不足")else:    print("购买成功")

转载地址:http://asgfk.baihongyu.com/

你可能感兴趣的文章
MySQL定义和变量赋值
查看>>
mysql定时任务事件清理单表数据
查看>>
MySQL定时器Events
查看>>
mysql实战01|基础架构:一条SQL查询语句是如何执行的?
查看>>
Mysql实战之数据备份
查看>>
MySQL实战教程:从小白到大神的进阶之路!
查看>>
mysql实现成绩排名
查看>>
Mysql客户端中文乱码问题解决
查看>>
mysql客户端工具使用
查看>>
MySQL密码忘记,怎么办?
查看>>
mysql对同一张表进行查询和赋值更新
查看>>
mysql导入数据库出现:Incorrect string value: '\xE7\x82\xB9\xE9\x92\x9F' for column 'chinese' at row 1...
查看>>
mysql导入(ibd文件)
查看>>
Mysql工作笔记006---Mysql服务器磁盘爆满了_java.sql.SQLException: Error writing file ‘tmp/MYfXO41p‘
查看>>
MySQL工具1:mysqladmin
查看>>
mysql常用命令
查看>>
MySQL常用命令
查看>>
mysql常用命令
查看>>
MySQL常用指令集
查看>>
mysql常用操作
查看>>