Back to Freecodecamp

Step 2

curriculum/challenges/english/blocks/workshop-binary-search/683ec95f2f8781355556ff7a.md

latest975 B
Original Source

--description--

The binary search algorithm you're building will not just return True or False to indicate whether the value was found or not. It will also return the path it takes to find that value. And for that, you will have a path_to_target variable to track the path.

Inside your binary_search function, replace the pass keyword with a path_to_target variable and initialize it to an empty list, for a start.

--hints--

You should create a path_to_target variable set to an empty list within your binary_search function. Don't forget to remove the pass keyword.

js
({ 
  test: () =>
    assert(
      runPython(
        `_Node(_code).find_function("binary_search").find_body().is_equivalent("path_to_target = []") and not _Node(_code).find_function("binary_search").has_pass()`
      )
    ) 
})

--seed--

--seed-contents--

py
--fcc-editable-region--
def binary_search(search_list, value):
    pass
--fcc-editable-region--