Tell us what’s happening:
Step 15, printing an empty list and message. I have tried it as format string, and as tuple of and message. I ma at a loss.
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)
if value == value_at_middle:
return path_to_target
elif value > value_at_middle:
low = mid + 1
else:
high = mid - 1
# User Editable Region
return f"{[]}, Value not found"
# User 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))
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:148.0) Gecko/20100101 Firefox/148.0
Challenge Information:
Implement the Binary Search Algorithm - Step 15