Recursive program to insert a star between pair of identical characters | Function to insert * at desired position ; Append current character ; If we reached last character ; If next character is same , append '* ; Driver code
def pairStar ( Input , Output , i = 0 ) : NEW_LINE INDENT Output = Output + Input [ i ] NEW_LINE if ( i == len ( Input ) - 1 ) : NEW_LINE INDENT print ( Output ) NEW_LINE return ; NEW_LINE DEDENT DEDENT ' NEW_LINE INDENT if ( Input [ i ] == Input [ i + 1 ] ) : NEW_LINE INDENT Output = Output + ' * ' ; NEW_LINE DEDENT pairStar ( Input , Output , i + 1 ) ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT Input = " geeks " NEW_LINE Output = " " NEW_LINE pairStar ( Input , Output ) ; NEW_LINE DEDENT