# How to prove that a continuous mapping from a compact, connected space..

If $f$ is a continuous mapping from a compact, connected metric space M to the real numbers and there exists a real number s such that f(m) never equals s, then there exists a constant $c>0$ such that either $f(m)>s+c$ or $f(m)<s-c.$ Intuitively this makes sense but I can't come up with a proof.

• This is related to your previous question, asked from a different account. (If you are going to continue using this site, you should register your account: see the profile link on top of the screen). In addition to what was done there, use the fact that a continuous function function attains extreme values on a compact set. – user147263 Feb 2 '15 at 2:15
• sorry, I couldn't figure out how to ask it with the same one – Gigi Feb 2 '15 at 2:18
• does the metric space necessarily have to be compact for this to be true? – Gigi Feb 2 '15 at 2:24
• Think of a continuous function on $(0,1)$ that does not attain its supremum and infimum. – user147263 Feb 2 '15 at 2:25
• You need compactness to be sure that the image is compact, and connectedness to be sure that the image is connected. You need both properties to conclude your result. – Ian Feb 2 '15 at 3:22