figure converting an integer to string in base the code below shows the python code that implements the algorithm outlined above for any base between and def to_str(nbase)convert_string " abcdefif basereturn convert_string[nelsereturn to_str( basebaseconvert_string[ base print(to_str( )notice that in line we check for the base case where is less than the base we are converting to when we detect the base casewe stop recursing and simply return the string from the convertstring sequence in line we satisfy both the second and third laws by making the recursive call and by reducing the problem size using division let us trace the algorithm againthis time we will convert the number to its base string representation (" "figure shows that we get the results we are looking forbut it looks like the digits are in the wrong order the algorithm works correctly because we make the recursive call first on line then we add the string representation of the remainder if we reversed returning the convertstring lookup and returning the tostr callthe resulting string would be backwardbut by delaying the concatenation operation until after the recursive call has returnedwe get the result in the proper order this should remind you of our discussion of stacks back in the previous self check write function that takes string as parameter and returns new string that is the reverse of the old string recursion