[Math] Describe all continuous function from the reals to the discrete metric space

continuityreal-analysis

I was reading the discussion here but I don't find a satisfactory answer. The question is:

Let X = $\mathbb{R}$ with the usual metric and let X′ be a discrete metric
space. Describe all continuous functions from X to X′.

Specifically, here's my question, since every set in the discrete metric space is open and closed, then the inverse image of any $U \subset X$ has to be open and closed. I can't find any subsets that are open and closed in $\mathbb{R}$, except for $\mathbb{R}$ itself. Does that mean the only function is $f(x) = k\ \forall x \in \mathbb{R}$? That is, the constant function?

UPDATE

How should I think about it from the connectedness angle? One of the hints given is

discrete metric is totally disconnected. but $\mathbb{R}$ is connected.

I'm not sure how I can use the hint?

Best Answer

The continuous image of a connected space is connected. Since a discrete space is totally disconnected, the only connected subspaces of $X'$ are singletons. Thus the image of a continuous function from $\mathbb{R}$ into $X'$ must be a singleton; i.e., the function must be constant.