Let $f:X \rightarrow Y$ continuous where the metric space $(X,d)$ is connected. On $Y$ we use the discrete metric. I want to show that $f$ must be constant on $X$. My approach:
We may assume that $|X| \geq 2$ (otherwise the claim is trivial). Let $x_0 \in X$. Assume $\exists y \in X: f(x) \neq f(y)$. Define $$ V:= \{ x \in X \mid f(x) = f(x_0) \} $$ and $$ W := \{x \in X \mid f(x) \neq f(x_0)\} $$ We have $V \cup W = X, V \cap W = \emptyset$ en $V,W \neq \emptyset$ by the assumption. I want to show that both $V,W$ are open to get a contradiction with the fact that $X$ is connected. By the continuity-property we know $$ \forall x \in X \exists \delta_x > 0 \forall y \in X : d(x,y) < \delta_x \rightarrow f(x) = f(y) $$ Let $x \in V$. Then $B(x,\delta_x) \subseteq V$ thus $V$ is open. Let $x \in W$. Then $f(x) \neq f(x_0)$. Further we have for all $y \in B(x,\delta_x)$ that $f(y) = f(x) $ and thus $f(y) \neq f(x_0)$ s.t. $B(x,\delta_x) \subseteq W$.
Is there an easier way to conclude this ?