title: Check first a few digit of every line in a string, if they are equal, print a part of those lines together
body: <p>For example I have a string which is</p>
  <pre><code>textstring= &quot;&quot;&quot;
  0000 Onn ch=1 n=60 v=50   
  0000 Onn ch=1 n=67 v=50
  9600 Off ch=1 n=67 v=00
  9600 Off ch=1 n=60 v=00
  9600 Onn ch=1 n=62 v=50
  9600 Onn ch=1 n=69 v=50
  1920 Off ch=1 n=69 v=00
  1920 Off ch=1 n=62 v=00
  &quot;&quot;&quot;   
  </code></pre>
  <p>When the first four digit of lines are equal, for example <code>9600</code>, how can I print 67/60/62/69 together? (which is from each of the four lines after <code>n=</code>)</p>
  <p>I have tried something like below, but I don't think it work as expected</p>
  <pre><code>for i, char in enumerate(textstring):
      if char==&quot;O&quot; and (textstring[i+1]==&quot;f&quot; or textstring[i+1]==&quot;n&quot;):
          if textstring[i-5]==textstring[i+18] and textstring[i-4]==textstring[i+19] and textstring[i-3]==textstring[i+20] and textstring[i-2]==textstring[i+21]:
              if char==&quot;n&quot; and textstring[i+1]==&quot;=&quot;:  #we look for &quot;n=&quot; in the text
                  note=int (textstring[i+2]+textstring[i+3])  #we restore the int from string after &quot;n=&quot;, the use it as a note
                  note2=int (textstring[i+25]+textstring[i+26])
                  print(note)
                  print(note2)
  </code></pre>