I have a long list of tuples, could look like this for example:
[('5','9'), ('10','11'), ('1','2'), ('1','3'), ('1','4'), ('2','7'), ('3','8'), ('2','1'), ('3','1'), ('3','4'), ('5','6'), ('5','10'), ('10','12'), ('11','13'), ('13','14')]
I need to combine them into lists if they share anything in common. So the output in the example would be:
['11', '10', '13', '12', '14', '5', '6', '9']
['1', '3', '2', '4', '7', '8']
To clarify: the input is a list of tuples. I need to combine all tuples with shared element into one list. So if I will have: [('1','2'), ('1','3'), ('1','4'), ('4','5')], all the elements should all be put into one list ['1', '2', '3', '4', '5'], because they are linked through the tuples.
I tried to come up with something going through dictionaries byt failed miserably. I am sure there some "easier" solution.
thank you Martin