title: How to do a binary search for a range of the same value?
body: <p>I have a sorted list of numbers and I need to get it return the range of index that the number appears. My list is:</p>
  
  <pre><code>daysSick = [0, 0, 0, 0, 1, 2, 3, 3, 3, 4, 5, 5, 5, 6, 6, 11, 15, 24]
  </code></pre>
  
  <p>If I searched 0, I need to return (0, 3). Right now I can only get it to find the spot of one number! I know how to do the binary search, but I am stuck how to make it move up and down from the position to find the other same values! </p>
  
  <pre><code>low = 0
  high = len(daysSick) - 1
  while low &lt;= high :
      mid = (low + high) // 2
      if value &lt; daysSick[mid]:
          high = mid - 1
      elif value &gt; list[mid]:
          low = mid + 1
      else:
          return mid
  </code></pre>