I want to find the matching item from the below given list.My List may be super large.
The very first item in the tuple "N1_10" is duplicated and matched with another item in another array
tuple in 1st array in the ListA ('N1_10', 'N2_28')
tuple in 2nd array in the ListA ('N1_10', 'N3_98')
ListA = [[('N1_10', 'N2_28'), ('N1_35', 'N2_44')],
[('N1_22', 'N3_72'), ('N1_10', 'N3_98')],
[('N2_33', 'N3_28'), ('N2_55', 'N3_62'), ('N2_61', 'N3_37')]]
what I want for the output is
output --> [('N1_10','N2_28','N3_98') , ....
and the rest whatever match one of the
key will get into same tuple]
If you guys think , changing the data structure of the ListA is better option , pls feel free to advise! Thanks for helping out!
SIMPLIFIED VERSION
List A = [[(a,x),(b,k),(c,l),(d,m)],[(e,d),(a,p),(g,s)],[...],[...]....]
wantedOutput --> [(a,x,p),(b,k),(c,l),(d,m,e),(g,s).....]