find repeated element in list of list python
<p>I have been struggling with this problem for two days and I need help with it. I need to find repeated element in a list of lists
<code>list_of_list = [(a1, b1, c1), (a2, b2, c2), ..., (an, bn, cn)]</code> where "a" and "b" elements are integers and "c" elements are floats.</p>

<p>So if for example <code>a1 == a2</code> or <code>a1 == bn</code>, I need to create a new list with the entire list elements and I need to iterate this for all the lists (a, b, c) in the list of lists. To put it another way, I need all lists that have elements that are present in more than one list. I need to compare only "a" and "b" elements but obtain the associated value "c" in the final list.</p>

<p>For example:</p>

<pre><code>list_of_list = [(1, 2, 4.99), (3, 6, 5.99), (1, 4, 3.00), (5, 1, 1.12), (7, 8, 1.99) ]

desired_result=[(1, 2, 4.99), (1, 4, 3.00), (5, 1, 1.12)] 
</code></pre>

<p>I try many ideas...but nothing nice came up:</p>

<pre><code>MI_network = [] #repeated elements list
genesis = list(complete_net) #clon to work on
genesis_next = list(genesis) #clon to remove elements in iterations
genesis_next.remove(genesis_next[0])

while genesis_next != []:
    for x in genesis:
        if x[0] in genesis_next and x[1] not in genesis_next:
            MI_network.append(x)
        if x[0] not in genesis_next and x[1] in genesis_next:
            MI_network.append(x)
    genesis_next.remove(genesis_next[0])
</code></pre>

<p>Using your idea, you can try this:</p>

<pre><code>MI_network = []
complete_net = [(1, 2, 4.99), (3, 6, 5.99), (1, 4, 3.00), (5, 1, 1.12), (7, 8, 1.99)]
genesis = list(complete_net)

while genesis != []:
    for x in genesis:
        for gen in genesis:
            if x[0] in gen and x[1] not in gen:
                if x[0] != gen[2] and x[1] != gen[2]:
                    if x not in MI_network:
                        MI_network.append(x)
            elif x[0] not in gen and x[1] in gen:
                if x[0] != gen[2] and x[1] != gen[2]:
                    if x not in MI_network:
                        MI_network.append(x)
            elif x[0] not in gen and x[1] not in gen:
                pass
    genesis.remove(genesis[0])   

print(MI_network)
[(1, 2, 4.99), (1, 4, 3.0), (5, 1, 1.12)]
</code></pre>

python list element