Function to flip the bits of string
def flip ( s ) : NEW_LINE INDENT arr = list ( s ) NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if ( arr [ i ] == '1' ) : NEW_LINE INDENT arr [ i ] = '0' NEW_LINE DEDENT else : NEW_LINE INDENT arr [ i ] = '1' NEW_LINE DEDENT DEDENT s = ' ' . join ( arr ) NEW_LINE return s NEW_LINE DEDENT