extracting tuple values from list of tuples
<p>I have a list containg tuples of different types like:</p>

<pre><code>[(0, 1, 'BLANK', ''), (0, 2, 'PERSON', 'Deraj'), (3, 8, 'DOB', 'April 27 , 1834'), (9, 11, 'PERSON', 'David Deraj'), (11, 13, 'LOC', 'Pennsylvania'), (16, 19, 'PERSON', 'Mary Deraj')]
</code></pre>

<p>How do i get the following output</p>

<pre><code>('Deraj', 'David Deraj')
('Deraj', 'Mary Deraj')
</code></pre>

<p>i am trying to use for loop:</p>

<pre><code>for i in l:
    if i[2] == 'PERSON':
        m = list(i[3])
</code></pre>

<p>but this doesnt work.</p>

<p>You probably can do it like this(if i understand correctly and you want first member of tuple to be second name of those peoples):</p>

<pre><code>l=[]
for i in l:
  if i[2]=='PERSON':
      temp=i[3].split()
      if len(temp)&gt;1: 
        l.append((temp[1],i[3]))
</code></pre>

python list python-3.x tuples