-2
我有一组列表,我想先比较两个或多个列表中具有相同值的列表的总和值,然后单个元素。为彻底的赢家基于python3中的值分离列表
my_list1 = [2, 3, 2, 4, 5]
my_list2 = [1, 3, 2, 3, 2]
my_list3 = [1, 1, 2, 2, 2]
my_list4 = [3, 2, 2, 4, 5]
逻辑测试是不错,但我遇到的问题是,在平局的情况下,隔离列表 - 上面my_list1
和my_list4
场景所以会被隔离进行进一步的逻辑测试,他们的总数都来到16
。
这是我迄今为止
my_list1=[1,1,2,2,2]
my_list2=[1,1,1,1,2]
my_list3=[2,2,1,1,2]
my_list1Total=sum(my_list1)
my_list2Total=sum(my_list2)
my_list3Total=sum(my_list3)
if my_list1Total>my_list2Total and my_list1Total>my_list3Total:
print("List one has the higest score")
elif my_list2Total>my_list1Total and my_list2Total>my_list3Total:
print("List two has the higest score")
elif my_list3Total>my_list2Total and my_list3Total>my_list1Total:
print("List three has the higest score")
else:
print("Draw")
##so now I want to compare the lists with the same total but this time by the first element in the list. In this case it would be my_list1[0] and my_list3[0] that would be compared next. The winner having the highest value in position 0 of the drawing lists
你试过了什么,你得到的输出是什么,你期望的是什么? – jonrsharpe 2014-10-28 11:16:29