TITLE: Prove that there cannot be a continuous onto function $f :\Bbb R \to \Bbb R \setminus \Bbb Q$
QUESTION [7 upvotes]: Prove that there cannot be a continuous onto function $f :\Bbb  R \to \Bbb R \setminus \Bbb Q$
Please let me know if you agree with my proof:
Suppose, toward a contradiction, that there exists such a continuous onto function $f :\Bbb  R \to \Bbb R \setminus \Bbb Q$ . Since $\Bbb R$ is connected, $f(\Bbb R) \subset \Bbb R\setminus \Bbb Q$ must also be connected. Pick any $q \in \Bbb Q$ and let $U=(\infty, q)$ and $V=(q, \infty)$. Note that $U$ and $V$ are non-empty, disjoint and open. Then $U\cup V$ is a disconnection of $\Bbb R\setminus \Bbb Q$, a contradiction. Furthermore, ${\Bbb R}=f^{-1}(U \cup V)$ is also a contradiction since $\Bbb R$ is connected.

REPLY [3 votes]: Your proof just needs a cleaning up; set, for simplicity, $\mathbb{I}=\mathbb{R}\setminus\mathbb{Q}$. If $q\in\mathbb{Q}$, then
$$
(-\infty,q)\cap\mathbb{I}
\qquad\text{and}\qquad
(q,\infty)\cap\mathbb{I}
$$
are nonempty, disjoint and open subsets of $\mathbb{I}$, whose union is $\mathbb{I}$. Thus $\mathbb{I}$ is not connected and therefore it cannot be the image of a continuous function from a connected space.
The last sentence should be removed as it's inessential and badly written.

Actually, much more can be said: any continuous function $f\colon \mathbb{R}\to\mathbb{I}$ is constant, because every subset of $\mathbb{I}$ with at least two points is disconnected. Indeed, if $a\ne b$ are elements of $X\subset\mathbb{I}$, take a rational $q$ such that $a<q<b$ and repeat the argument above with $(-\infty,q)\cap X$ and $(q,\infty)\cap X$.