Given a sorted list of integers and a naturl number \(x\). Your task is to find the index of element \(x\) in logarithmic time.
write a function search(sorted_list: list, x: int)
. This function returns the index of element \(x\). If there is no such element return None
.
>>> search([0, 2, 4, 6, 8, 10, 12, 14], 4)
2
>>> search([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 5)
5
>>> search([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0)
0
>>> search([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1)
1
>>> search([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 3)
3
>>> search([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 10)