【发布时间】:2019-11-14 17:30:10
【问题描述】:
在 Python 中迈出第一步。 我有一个列表列表,我正在尝试返回所有子列表中总和最大的 子列表。 现在我只有最大和本身。 例如:此代码返回 18,但我需要返回 [3,3,3,3,3,3]
有什么方向吗? 谢谢
def find_biggest(lst):
inner_list_sum = []
for i in range(len(lst)):
inner_list_sum.append(sum(lst[i])) # list of elements sums
return max(inner_list_sum) # I actually need the element itself...not the max sum
print(find_biggest([[1,2,3,4], [1,2,3,3], [1,1], [3,3,3,3,3,3]]))
【问题讨论】:
标签: python python-3.x python-requests