curriculum/challenges/english/blocks/workshop-binary-search/68416aab85dd00a7852cdeb6.md
You can see that the last call prints an empty list. To further specify that the value is not in the searched list, update the return statement and return an empty list and the message Value not found.
You should update the return statement to return [], 'Value not found'.
({
test: () =>
assert(
runPython(
`_Node(_code).find_function("binary_search").has_return("[], 'Value not found'")`
)
)
})
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)
if value == value_at_middle:
return path_to_target
elif value > value_at_middle:
low = mid + 1
else:
high = mid - 1
--fcc-editable-region--
return []
--fcc-editable-region--
print(binary_search([1, 2, 3, 4, 5], 3))
print(binary_search([1, 2, 3, 4, 5, 9], 4))
print(binary_search([1, 3, 5, 9, 14, 22], 10))