我在词典列表中包含以下数据。如何根据以下规则有效比较这两者,并得出谁是赢家?如何有效比较两个词典列表以声明“获胜者”
if any value in a list turns out to be more than all the other values of the other list , The list with bigger value will be declared the winner
s1=[{'link': 0}, {'link': 0}]
s2=[{'link': 0}, {'link': 1}]
我的尝试是:
for stat in s2:
for stat1 in s1:
if stat['link'] >= stat1['link']:
print('success')
你确定你的总体订购是否足够精确? “s2大于s1,因为s2中的其中一个值大于s1中的值” –
如果列表中的任何值比另一个列表中的所有其他值多,则值较大的列表将会被宣布为优胜者 – Zuckerberg
只是要清楚:你所说的是你不需要逐个比较元素。价值最高的名单是胜利者。问题的描述不反映这种说法。你应该更新你的问题的描述。 – Thanassis