Change A to B and B to A
temp1 = [ y for y in prev ] NEW_LINE for i in range ( len ( prev ) ) : NEW_LINE INDENT if ( temp1 [ i ] == ' A ' ) : NEW_LINE INDENT temp1 [ i ] = ' B ' NEW_LINE DEDENT else : NEW_LINE INDENT temp1 [ i ] = ' A ' NEW_LINE DEDENT DEDENT