Necessary and sufficient condition for the continuity of a function Let $E$ be a topological space and $A\subset E$ how to find a necessary and sufficient condition for the continuity of the function $\chi_A: E\rightarrow\mathbb{R}$ where 
$$
\chi_A(x)=
\begin{cases}
1, ~x\in A\\ 
0,~x\not\in A
\end{cases}
$$
If i suppose that $\chi_A$ is continuous  then $$\forall\varepsilon>0, \exists V\in \mathcal{V}_x, \chi_A(V)\subset ]\chi_{A}(x)-\varepsilon, \chi_A(x)+\varepsilon[$$ or 
 $$\forall\varepsilon>0, \chi_A^{-1}(]\chi_{A}(x)-\varepsilon, \chi_A(x)+\varepsilon[)\in \mathcal{V}_x $$
How to find a condition on $A$? 
Thank you

Necessary and sufficient condition for $\chi_A$ to be continuous is that $A$ is both open and closed.
Necessity. If $\chi_A$ is continuous, then $\chi_A^{-1}(-\infty,1/2)=X\setminus A$, $\chi_A^{-1}(1/2, \infty)=A$ are open.
Sufficiency. Assume that $A$ and $X\setminus A$ are both open, and $U\subset\mathbb R$ open. Then
$$
\chi_A^{-1}(U)=\left\{
\begin{array}{ccc}
X &\text{if}& 0,1\in U,\\
A&\text{if}& 1\in U \,\&\, 0\not\in U\\
X\setminus A&\text{if}& 0\in U \,\&\, 1\not\in U\\
\varnothing&\text{if}& 0,1\not\in U. 
\end{array}
\right.
$$ 
and hence 
$\chi_A$ is continuous.
