Suppose that $f: \mathbb{R} \to \mathbb{R}$ is continuous and that $f(x) \in \mathbb{Q}$ for all $x \in \mathbb{R}$. Prove that f is constant.
I have the idea that because there is an irrational number between any two rational number then if the function is continuous, the function must be constant. But I don't know how to write out a proper proof for it.
Any help is appreciated. Thanks in advance.