human
Search in an array of strings where non | Compare two string equals are not.
Main function to find string location.
Move mid to the middle.
If mid is empty , find closest non - empty string.
If mid is empty , search in both sides of mid and find the closest non - empty string , and set mid accordingly ..
If str is found at mid.
If str is greater than mid.
If str is smaller than mid.
Driver Code.
Input arr of Strings ..
input Search String"
How can the above be solved in Python?

Can you provide a code to search in an array of strings where non and the other steps required?
assistant
#Here is code to search in an array of strings where non and the other steps required.
 def compareStrings ( str1 , str2 ) :
	i = 0
	while i < len ( str1 ) - 1 and str1 [ i ] == str2 [ i ] :
		i += 1
	if str1 [ i ] > str2 [ i ] :
		return - 1
	return str1 [ i ] < str2 [ i ]
def searchStr ( arr , string , first , last ) :
	if first > last :
		return - 1
	mid = ( last + first ) // 2
	if len ( arr [ mid ] ) == 0 :
		left , right = mid - 1 , mid + 1
		while True :
			if left < first and right > last :
				return - 1
			if right <= last and len ( arr [ right ] ) != 0 :
				mid = right
				break
			if left >= first and len ( arr [ left ] ) != 0 :
				mid = left
				break
			right += 1
			left -= 1
	if compareStrings ( string , arr [ mid ] ) == 0 :
		return mid
	if compareStrings ( string , arr [ mid ] ) < 0 :
		return searchStr ( arr , string , mid + 1 , last )
	return searchStr ( arr , string , first , mid - 1 )
if __name__ == " _ _ main _ _ " :
	arr = [ " for " , " " , " " , " " , " geeks " , " ide " , " " , " practice " , " " , " " , " quiz " , " " , " " ]
	string = " quiz "
	n = len ( arr )
	print ( searchStr ( arr , string , 0 , n - 1 ) )