# In a non-compact metric space, topological transitivity need not imply onto

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 converse of the above is not true and the compactness hypothesis cannot be removed.

To show that converse is not true, I let $X=\{0,1\}$ with discrete topology and $f$ be the identity map on $X.$ Then $f$ is onto but not topologically transitive.

However, 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.$

Start from the bilateral shift on 2 letters $K=\{0,1\}^{\mathbf{Z}}$, with the shift $s(f)(n)=f(n-1)$. It is clearly topologically transitive, and hence so is any open subset stable under $s$. One particular open subset $U$ is the complement of the set $F=\{0\}\cup\{\delta_n:n\le 0\}$, where $\delta_n(m)=1$ iff $m=n$ ($F$ is clearly closed and stable under $s^{-1}$). So $(U,s)$ is a locally compact example.