The goal of binary search is to search whether a given number is present in the string or not. First, check whether it is present in the middle or not then check for front and rear using Python.