会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132471个问题

老师看下附件代码哪错了

错.gif

goods = [
    {"name": "面包", "mount": 7, "price": 5},
    {"name": "牛奶", "mount": 3, "price": 10},
    {"name": "香蕉", "mount": 1, "price": 12},
    {"name": "大米", "mount": 2, "price": 98}
    ]
def showGoods(x):
    print("--- 商品信息 ---")
    count = 0
    a = 0
    money = 0
    for i in x:
        print(f"{count}",i["name"],i["mount"],i["price"])
        count += 1
        start = (i[a]["mount"])*(i[a]["price"])
        a += 1
        money += start
    return money
    
    
showGoods(goods)
print(f"本次购物总价为{showGoods(goods)}元")


Python 全系列/第一阶段:Python入门/Python入门(动画版) 2222楼
Python 全系列/第一阶段:Python入门/函数和内存分析 2225楼
Python 全系列/第一阶段:Python入门/编程基本概念 2226楼
Python 全系列/第一阶段:Python入门/控制语句 2230楼
Python 全系列/第一阶段:Python入门/编程基本概念 2231楼
Python 全系列/第一阶段:Python入门/Python入门(动画版) 2232楼
Python 全系列/第一阶段:Python入门/编程基本概念 2233楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637