What's the easiest way to check weather an object is in a sorted list? I have found bisect, but that only finds the insertion points. Sure this index could then be used to check if the object exists in the list. But is there a easier way?
Something similar to the "in" command? Returning a True/False but for sorted lists?
bisectlets you find the insertion point, how you could check if the value is in the list at that point..bisect_left(), and you don't have to subtract. You'll have to account for the possibility that the resulting index is 1 higher than the last valid index. So useidx = bisect_left(L, n)and then useidx < len(L) and L[idx] == n.