<prompt> Kuandika search ternary katika Python.  <response>: Heres an implementation of ternary search in Python:def ternary_searcharr, left, right, x: if right left: mid1 left right - left 3 mid2 right - right - left 3 if arrmid1 x: return mid1 elif arrmid2 x: return mid2 elif x arrmid1: return ternary_searcharr, left, mid1-1, x elif x arrmid2: return ternary_searcharr, mid21, right, x else: return ternary_searcharr, mid11, mid2-1, x return -1To use this function, pass in the array arr, the left and right indices of the subarray you want to search, and the target value x. Call the function like this:arr 1, 2, 3, 4, 5, 6, 7, 8, 9x 5result ternary_searcharr, 0, lenarr-1, xif result ! -1: printfElement x is found at index resultelse: printElement is not present in arrayThis script will output:Element 5 is found at index 4 