title: How can I count a word from all lines that are 2 rows after a specific line?
body: <p>So, this might sound a bit confusing, I'll try to explain it. For example from these lines:</p>
  
  <pre><code>next line 1
  ^^^^^^^^^^^^^^^^^^
  red blue dark ten lemon
  next line 2
  ^^^^^^^^^^^^^^^^^^^
  hat 45 no dad fate orange
  next line 3
  ^^^^^^^^^^^^^^^^^^^
  tan rat lovely lemon eat 
  you him lemon Daniel her"
  </code></pre>
  
  <p>I am only interested in the count of "lemon" from lines that have "next line" two lines above it. So, the output I expect is "2 lemons". </p>
  
  <p>Any help will be greatly appreciated! </p>
  
  <p>My attempt so far is:</p>
  
  <pre><code>#!/usr/bin/env python
  #import the numpy library
   import numpy as np
  
    lemon = 0
  
    logfile = open('file','r')
  
    for line in logfile:
  
    words = line.split()
  
    words = np.array(words)
    if np.any(words == 'next line'):
      if np.any(words == 'lemon'):
          lemon +=1
  print "Total number of lemons is %d" % (lemon)
  </code></pre>
  
  <p>but this counts "lemon" only if it's on the same line as "next line".</p>