I'd like to say that it isn't.
Consider the set $\{1\}$ in $\mathbb{Z}$, where $k$ is some integer. It is open because it equals $(0.5,1.5)\cap \mathbb{Z}$, and $(0.5,1.5)$ is open in $\mathbb{R}$.
If we take $I^{-1}(\{1\})$, we get $[1,2)$, which isn't open in $\mathbb{R}$. Hence, the function isn't continuous.
You're right.
More generally, let $X$ be connected and $Y$ be discrete. A map $f: X \rightarrow Y$ is continuous if and only if it is constant.