나는 목록의 합계 값을 먼저 비교하고 같은 값을 가진 두 개 이상의 목록이있는 경우 개별 요소를 비교하기를 원하는 목록 집합을 가지고 있습니다. 명백한 승자에 대한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