title: Group numbers into ranges in Python
body: <p>I want to group the numbers in different regions automatically. As per the figure (<em>sample dataset</em>), we can see that their are three regions in which numbers are lying i.e. <strong>[0,100], [650,750], [1220, 1300]</strong>. I want to point those regions only. There can be any number of such regions. We need to automatically find the no. of such regions and range of such regions. The distance between two regions will be considerably very high.
  Is there any way I can do this in Python?</p>
  <pre class="lang-py prettyprint-override"><code>Sample data = [69,  8,  30, 45, 89, 61, 80, 45, 9,  18, 19, 11, 1255,   1299,   1296,   1293,   1287,   1250,   1265,   1291,   1281,   1250,   1286,   1286,   1251,   1287,   1266,   1288,   1254,   1260,   1260,   1254,   1267,   1299,   1273,   1250,   1300,   1250,   1279,   1255,   1293,   1292,   1278,   1277,   1252,   1299,   1278,   1258,   1268,   1274,   1285,   1258,   1279,   1270,   1278,   1286,   1278,   1253,   1267,   1300,   1295,   1298,   1285,   1288,   1274,   1272,   1252,   1256,   1283,   1289,   1251,   1258,   1253,   1257,   1297,   1269,   1292,   1253,   1273,   1281,   1251,   1280,   1253,   1274,   1275,   1287,   1296,   1298,   1296,   1291,   1284,   1261,   1267,   1290,   1273,   1281,   1263,   1270,   1264,   1269,   1278,   1284,   67, 8,  40, 59, 97, 64, 45, 72, 45, 90, 94, 7,  33, 58, 97, 97, 1252,   1297,   1265,   1278,   1272,   1252,   1258,   1261,   1287,   1260,   1260,   1258,   1280,   1263,   1256,   1296,   1269,   1270,   1296,   1282,   696,    678,    665,    700,    700,    691,    689,    688,    650,    663,    662,    698,    655,    660,    662,    684,    690,    657,    653,    663,    670,    691,    687,    675,    694,    670,    676,    659,    661,    664,    664,    689,    683,    675,    687,    691,    676,    659,    689,    657,    659,    656,    654,    679,    669,    687,    666,    662,    691,    1260,   1276,   1252,   1295,   1257,   1277,   1281,   1257,   1295,   1269,   1265,   1290,   1266,   1269,   1286,   1254,   1260,   1265,   1290,   1294,   1286,   1279,   1254,   1256,   1276,   1285,   1282,   1251,   1282,   1261,   1253,   56, 74, 85, 94, 18, 83, 38, 80, 8,  4,  78, 43, 7,  79, 68, 78, 1275,   1250,   1268,   1297,   1284,   1255,   1294,   1262,   1250,   1252,   680,    693,    677,    676,    670,    653,    670,    661,    658,    695,    665,    671,    656,    686,    662,    691,    675,    658,    671,    650,    667,    653,    652,    686,    667,    682,    694,    654,    689,    682,    667,    658,    651,    652,    692,    652,    655,    651,    650,    698,    655,    650,    679,    672,    697,    696,    696,    683,    1277,   1264,   1274,   1260,   1285,   1285,   1283,   1259,   1260,   1288,   1281,   1284,   1281,   1257,   1285,   1295,   1273,   1264,   1283,   1284,   1300,   1299,   1257,   1297,   1254,   1257,   1270,   1257,   1295,   34, 5,  73, 42, 27, 36, 91, 85, 19, 50, 34, 21, 73, 38, 18, 73]
  </code></pre>