I had asked [this](https://math.stackexchange.com/questions/2601034/in-a-non-compact-metric-space-topologically-transitivity-need-not-imply-onto) question on [Mathematics Stack Exchange](https://math.stackexchange.com/) yesterday but it got no response so I'm asking here.

---

Let $X$ be a compact metric space and $f:X \to X$ be continuous. If $f$ is topologically transitive. Then $f$ is onto.

>I'm trying to show that the compactness hypothesis cannot be removed. 

>I couldn't find any example of a non-compact metric space and a continuous function which is topologically transitive but not onto.

Any hints will be appreciated.

**Note:** If $(X,f)$ is a dynamical system. Then $f$ is said to be topologically transitive if for every pair of non-empty open sets $U$ and $V$ in $X$ there exists $n \geq 1$ such that $f^n(U) \cap V\neq \emptyset.$