Поиск симметричных внутренних элементов списка Python
def symmetrical_sum(a):
dup=[x for n, x in enumerate(a) if x in a[:n]] #to get the duplicate
to_int = int(''.join(map(str,dup))) #change duplicate into int
dup1_index=a.index(to_int) #index the first duplicate
dup2_index=a.index(to_int,dup1_index+1) #index the second duplicate
portion=a[dup1_index:dup2_index+1] #get the symetric portion
total = sum(portion) #sum the elements in portion
tuple1 = (portion,total) #create tuple
return tuple1
Africodes