Implement the Binary Search Algorithm - Step 9

Tell us what’s happening:

Step 9 of Implement the Binary Search Algorithm. I can’t do it.

Your code so far

def binary_search(search_list, value):
    path_to_target = []

    low = 0
    high = len(search_list) - 1

    while low <= high:
        mid = (low + high) // 2
        value_at_middle = search_list[mid]
        path_to_target.append(value_at_middle)

# User Editable Region


        if value == value_at_middle:
            break

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36

Challenge Information:

Implement the Binary Search Algorithm - Step 9

GitHub Link: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/workshop-binary-search/683ec95f2f8781355556ff81.md

Were you asked to change the if statement?

Please reset this step and try again. Only do what is asked. Do not change code you were not asked to change.

Is there something about tis instruction you do not understand?

Just after the if statement, use the break keyword to break out of the while loop. Then, after the while loop, return an empty list to signify that the value was not found.

I am still lost. I did not modify my if statement and it is still an error.

You did modify your if statement. This is what the starting code looked like:

        if value == value_at_middle:
            return path_to_target

thank you very much.