theList = [2, 3, 5, 7] x = 5 i = 0 while i < len(theList): if theList[i] == x: print "yes" break i = i + 1 lo = 0 hi = len(theList) while lo < hi: mid = (lo + hi)/2 if theList[mid] == x: print "yes" break if theList[mid] < x: lo = mid + 1 else: hi = mid