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.