-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