Python print next line while printing from for loop
<p>I am performing a for loop on a list and would like to find a match and print the next line.  However, when I try to use the next() method I keep getting a failure. Can I please get some help in extracting the next line after a specified match?</p>

<p>string (for loop output):</p>

<pre><code>item_0
0
item_1
0           




item_3
727

item_4
325
</code></pre>

<p>For Loop to find match and next line:</p>

<pre><code>result = tree.xpath('//tr/td/font/text()')

for line in result:
    if 'item_3' in line:
        print(line.next())
</code></pre>

<p>Error:</p>

<pre><code>AttributeError: '_ElementStringResult' object has no attribute 'next'
</code></pre>

<p>Haven't tested this, but try:</p>

<pre><code>result = tree.xpath('//tr/td/font/text()')

iter_result = iter(result)
for line in iter_result:
    if 'item_3' in line:
        print(next(iter_result))
</code></pre>

python match