title: Search function with time complexity O(lg n)
body: <p>I needed to create a search function with time complexity O(lgn) that would return the position that a certain value x would go in a tuple. </p>
  
  <p>For example, <code>search(8, (2, 7, 12))</code> would return 2,<br>
  <code>search(-5, (2, 3, 4, 10))</code> would return 0 and<br>
  <code>search(6, (4, 6, 12))</code> would return 1.
  with the tuple already sorted<br>
  I wrote the following code:</p>
  
  <pre><code>    def search(x,seq):
          for i in seq:
              if x&lt;i:
                  return seq.index(i)
              elif x == i:
                  return seq.index(i)
              elif x&gt;seq[-1]:
                  return (seq.index(seq[-1]))+1
  </code></pre>
  
  <p>Does this code have time complexity O(lgn)?</p>