Binary Search implementation in Python
I am trying to implement a solution using binary search. I have a list of numbers list = [1, 2, 3, 4, 6] value to be searched = 2 I have written something like this def searchBinary(list, sval): low = 0 high = len(list) while low < high: mid = low + math.floor((high - low) / 2) if list[mid] == sval: print("found : ", sval) elif l2s[mid] > sval: high = mid - 1 else: low = mid + 1 but when I am trying to implement this, I am getting an error like: index out of range. Please help in identifying the issue. cs95 A few things. Your naming is inconsistent. Also, do not use list as a variable name,