[Math] If $f:X \rightarrow \mathbb{Q}$ is continuous, then $f$ must be constant

connectednesscontinuitygeneral-topology

Let $X$ be a connected topological space. Prove if $f:X\to\mathbb Q$ is continuous, then $f$ must be constant.

I know the definition of continuous is: for all $x\in X$ and all neighbourhoods $N$ of $f(x)$ there is a neighborhood $M$ of $x$ such that $f(M)\subseteq N$. This relates easily to the usual definition in analysis. Equivalently, $f$ is continuous if the inverse image of every open set is open. But I don't know how to relate this to the proof I need to come up with.

Best Answer

The image of $f$ has to be connected. The only connected subsets of $\Bbb Q$ are points, as it is totally disconnected. So the image of $f$ is a point so it is constant.