I am developing a Binary Search function in Python. It is not working and shows up as a nothing coming up.
I have tried to set up the logic with Pseudocode and my teacher says that it works, however they have no idea why the algorithm and function are doing what they are doing. I have skinned the fat on my Pseudocode and multiple people have been able to fix my problem.
def binary_search(array,item):
start_point = 0
end_point = len(array)
mid_point = int((start_point + end_point) / 2)
array.sort()
print(array)it
while array[mid_point] != item:
if array[mid_point] > item:
start_point = mid_point
elif array[mid_point] < item:
end_point = mid_point
if array[mid_point] == item:
print(mid_point)
binary_search([0,99,2,6,4,8],7)
I want this function to work so that when you enter an array and a search term it shows where there is in the array (the index value)