# Describe all continuous function from the reals to the discrete metric space

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?

• Yes, that's exactly what it means. As a minor point, you would probably want to say "the constant functions" plural. – rnrstopstraffic Nov 16 '17 at 6:40
• @rnrstopstraffic Thank you. How should I think about it from the connectedness angle? – user1691278 Nov 16 '17 at 7:20
• @rnrstopstraffic updated the question – user1691278 Nov 16 '17 at 7:21
• As you've seen, John Griffin's answer answers your question. It's worth noting that your observation that every set in the descrete space is clopen and that the only clopen sets in $\mathbb{R}$ are $\mathbb{R}$ itself and $\emptyset$ are exactly what it means for $\mathbb{R}$ to be connected and for the discrete space to be (totally) disconnected. – rnrstopstraffic Nov 16 '17 at 23:54

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.