Option Bonus 2: Handling repeating numbers

I am having problems solving the bonus question.
I tried adding a while loop to the condition function to take care of repeating numbers but I don’t know what to return in order to get the binary_search function to skip over repeated numbers. Check out my notebook


The link is not working properly for me, could you post a screenshot of the code or post the code here.

i think it was provate before. Could you check now?

def soln(lst):

lo, hi = 0, len(lst) - 1

while lo <= hi:

    mid = (lo + hi)//2

    midNum = lst[mid]


    if midNum < lst[mid - 1]:

        return mid


    if midNum <= lst[-1]:

        hi = mid - 1


        lo = mid + 1

return 0

Is this solution correct?

Can anyone check if this works properly for the repetitive numbers in sorted list? or if anyone can provide a sample input for which it will fail so that I can work on it.

I am getting a feeling that there should be equal case also while comparing the number with previous one if it’s same and then moving to left and similar for right also.

Do let me know if I’m thinking wrong.

Thanks in advance