How to join two list of tuples without duplicates
<p>I am running two queries to a database, the result i get from each, is a list of tuples which is perfect. I would like to join these into one list of tuples. These are examples of the tuples: </p>

<pre><code>list1 = [('abc', 1 ),  ('def', 2) ... ]
list2 = [(1000, 'abc'),  (2000, 'def' ), (3000, 'def') ... ] 
</code></pre>

<p>I want to create just one list of tuples and i join them like this:</p>

<pre><code>q = []
for i in list1:
            for j in list2:         
                if i[0] == (j[1]):
                    i = i + (j[0],)
                    q.append(i)
</code></pre>

<p>This returns duplicates in my new list <code>q</code> as i get something like this:</p>

<pre><code>q = [('abc', 1 , 1000) , ('def', 2, 2000), ('def', 2, 2000, 3000) ...]
</code></pre>

<p>How can I avoid getting duplicates like the second list of tuples in the q list? 
I want just <code>('def', 2, 2000, 3000)</code> and not this <code>('def', 2, 2000), ('def', 2, 2000, 3000)</code></p>

<p>I've been stuck on this for a while so any help is appreciated. Thanks </p>