Modifying the string w according to th rules
for i in range ( l ) : NEW_LINE INDENT if ( pre [ i ] == True ) : NEW_LINE INDENT if ( w [ i ] == letter ) : NEW_LINE INDENT w [ i ] = ' b ' if ( letter == ' a ' ) else ' a ' NEW_LINE DEDENT DEDENT DEDENT