Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Search for a symmetrical inner elements of a list 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
Comment

PREVIOUS NEXT
Code Example
Python :: display list 
Python :: expected a list of items but got type int . django 
Python :: pd sample every class 
Python :: list generation for python 
Python :: python Entry default text 
Python :: fcn tensorflow 
Python :: Python - Comment vérifier une corde est vide 
Python :: python. printing varibles 
Python :: pandas math operation from string 
Python :: select columns rsnge dataframe 
Python :: comparing dict key with integer 
Python :: run persistent py script in background (good for flask) 
Python :: pythoon 
Python :: Define the learnable resizer utilities 
Python :: if statement in python with sets 
Python :: python timestamp human readable 
Python :: expand array to a certain size python 
Python :: split one str variable into two str variable using split 
Python :: What is the expected value of print to this program X = 2 Y = 3 Z = X + Y print(Y) #Z 
Python :: rtdpy ncstr 
Python :: how to code a discord bot in python nextcord 
Python :: type operator in python 
Python :: Insert Multiple Images to Excel with Python 
Python :: mhaan meaning in english 
Python :: how to load multiple list of dictionary values which is stored in python file and load into another python file in python over loop 
Python :: python: dunder init method 
Python :: convert math expression as string to int 
Python :: qtile: latest development version 
Python :: fibonacci sequence algorithm python 
Python :: pylatex subsection 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =