Check if both halves of the string have at least one different character | Function which break string into two halves Sorts the two halves separately Compares the two halves return true if any index has non - zero value ; Declaration and initialization of counter array ; Driver function
def function ( st ) : NEW_LINE INDENT st = list ( st ) NEW_LINE l = len ( st ) NEW_LINE st [ : l // 2 ] = sorted ( st [ : l // 2 ] ) NEW_LINE st [ l // 2 : ] = sorted ( st [ l // 2 : ] ) NEW_LINE for i in range ( l // 2 ) : NEW_LINE INDENT if ( st [ i ] != st [ l // 2 + i ] ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT st = " abcasdsabcae " NEW_LINE if function ( st ) : print ( " Yes , ▁ both ▁ halves ▁ differ ▁ " , " by ▁ at ▁ least ▁ one ▁ character " ) NEW_LINE else : print ( " No , ▁ both ▁ halves ▁ do ▁ not ▁ differ ▁ at ▁ all " ) NEW_LINE