If any character is not same as prev and next then return false
if ( ( s [ i ] != s [ i - 1 ] ) and ( s [ i ] != s [ i + 1 ] ) ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT i += 1 NEW_LINE return True ; NEW_LINE