title: How to calculate consecutive events?
body: <p>Given the following JSON object with the person's stay days in hotel per months:</p>
  
  <pre><code>[{u'month': u'7', u'stay_days': {u'value': 1.0}},
   {u'month': u'8', u'stay_days': {u'value': 1.0}},
   {u'month': u'9', u'stay_days': {u'value': 1.0}}]
  </code></pre>
  
  <p>I should check if the person visited the hotel at least one time per month during 2 consecutive months in the last 3 months.</p>
  
  <p>I get stuck with checking consecutive visits.</p>
  
  <pre><code>arr = '''[ {
              "stay_days": {
                  "value": 1.0
              }, 
              "month": "1"
          }, 
          {
              "stay_days": {
                  "value": 1.0
              }, 
              "month": "2"
          }, 
          {
              "stay_days": {
                  "value": 1.0
              }, 
              "month": "3"
          }]'''
  json_object = json.loads(arr)
  dt = datetime.strptime(datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%f'), "%Y-%m-%dT%H:%M:%S.%f")
  month = dt.month
  months = []
  for line in json_object:
      months.append(line["key"])
  months
  
  if (int(month) - int(max(months))) &gt; 0 and (int(month) - int(max(months))) &lt;= 3:  
      for line in json_object:
          # ???
  </code></pre>