title: Why does binary search algorithm not work?
body: <p>I've copied code from the book &quot;grokking algorithms&quot; for finding an item in the list using the binary search algorithm. The code launches great and returns no errors. However, sometimes it just doesn't work for certain numbers, for example if i call it to find &quot;1&quot;. What's wrong?</p>
  <pre><code>def binary_search(list, item):
      low = 0
      high = len(list) - 1
  
      while low &lt;= high:
          mid = (low + high)/2
          guess = list[mid]
          if guess == item:
              return mid
          if guess &gt; item:
              high = mid + 1
          else:
              low = mid + 1
      return None
  
  list1 = []
  
  for i in range (1, 101):
      list1.append(i)
  
  print(list1)
  print(binary_search(list1, 1))
  </code></pre>