试图修复我的功能 [英] Trying to fix my function

查看:67
本文介绍了试图修复我的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个函数,在该函数中我必须返回一个元组,其中第一个参数是最大数字的str,第二个参数是int的列表.这是示例,以及我为该函数编写的内容:

I'm working on a function where I have to return a tuple where the first parameter is a str of the highest number and the second parameter is a list of int. Here's the example and what I wrote for the function:

投票(['G','G','N','G','C']) ("G",[1、3、0、1]) ""

voting(['G', 'G', 'N', 'G', 'C']) ('G', [1, 3, 0, 1]) """

推荐答案

您必须将maxvalue的位置映射到正确的参与方:

You have to map the position of the maxvalue to the correct party:

parties = ['NDP', 'Green', 'Liberal', 'CPC']
winning_party = parties[total.index(max(total))]

这篇关于试图修复我的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆