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

Let's work locally. Take $x_0 \in E$. If $\chi_A$ is continuous at $x_0 \in E$, for every $\epsilon>0$ there is a neighbourhood $V$ of $x_0$ such that $x \in V$ implies $\chi_A(x) = \chi_A(x_0)$. So for all points in $A$ (for which $\chi_A(x_0)=1$, we find a neighbourhood of it which is contained in $A$, and so $A$ is open. Similarly for $A^c$ replacing $1$ by $0$ we find that $A$ is closed.
So $\chi_A$ continuous implies $A$ clopen. Conversely, if $A$ is clopen, take $(x_\alpha)$ a net converging to $x$. If $x \in A$, then $x_\alpha \in A$ for large $\alpha$ and so $\chi_A(x_\alpha) \to 1$. If $x \not\in A$, since $A^c$ is open, a similar argument shows that $\chi_A(x_\alpha)\to 0$. So $\chi_A$ is continuous.
