Invalid Syntax in Code

前端 未结 2 1970
攒了一身酷
攒了一身酷 2021-01-26 09:29

I am having trouble with this bit of code.

print(\"The Overall Winner is,\", sorted(data, key=lambda(x,y): sum(n[1] for n in y), reverse=True),sum(event[1] for e         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-26 09:40

    Your problem is that you're using argument unpacking in the lambda while using Python 3. Instead of doing this:

    lambda(x,y): sum(n[1] for n in y)
    

    Do this:

    lambda item: sum(n[1] for n in item[1])
    

提交回复
热议问题