title: Grouping the lists
body: <p>I'm writing a program where i need to group values from a list:</p>
  <pre><code>values = [73.0, 143.0, 323.0, 324.0, 325.0, 325.0, 325.0, 325.0, 325.5,
                325.5, 326.0, 326.0, 326.0, 326.0, 406.0, 406.5, 432.5, 433.0,
                433.5, 434.5, 435.0, 435.0, 436.0, 436.5, 437.5, 438.0
  </code></pre>
  <p>and a group is formed when there are at least seven elements and the difference between adjacent elements is less than 3.0</p>
  <p>And this is the list where the items have been subtracted:</p>
  <pre><code>diff_ar = [70.0, 180.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0,
                  0.0, 0.0, 80.0, 0.5, 26.0, 0.5, 0.5, 1.0, 0.5, 0.0, 1.0, 0.5,
                  1.0, 0.5]
  </code></pre>
  <p>The expected output should looks like this [(2,12), (16,24)]</p>
  <p>I need to return indexes of beginning and end of each group.</p>
  <p>I did something like this</p>
  <pre><code>list_1 = [y - x for x,y in zip(values,values[1:]) if (y-x)&lt;=3.0]
  </code></pre>
  <p>The output of this looks like this:</p>
  <pre><code>[1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 0.5, 0.0, 1.0, 0.5, 1.0, 0.5]
  </code></pre>
  <p>But now I don't know how to group it. I would be grateful if any of You could help.</p>