Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.3 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68416aab85dd00a7852cdeb6 Step 15 20 step-15

--description--

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.

--hints--

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'")`
            )
        )
})

--seed--

--seed-contents--

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))