# Under which conditions a non-compact and connected space possesses a non-constant continuous real-valued function

Is there an example of a non-compact and connected space $X$ such that constant functions are the only continuous functions from $X$ to $\mathbb{R}$ with the usual topology?

If the answer is "yes", I wonder under which conditions a non-compact and connected space possesses a non-constant continuous real-valued function.

Thank you.

Here is a easy example: An uncountable $X$ equipped with the cocountable topology is connected noncompact and the only continuous real-valued functions are constants. The proof is almost the same as the cofinite case.
Indeed, to admit a nonconstant $\mathbb{R}$-valued function means there is a nontrivial Hausdorff quotient $X\to f(X)$, and of course you can impose compactness there too since you can cut off $f$.
• You can also see that if $f:X\to \Bbb R$ is continuous and $f(x) \ne f(y)$ then $f^{-1}(-\infty, (f(x)+f(y))/2)$ and $f^{-1}((f(x)+f(y)/2,\;\infty)$ are disjoint non-empty subsets of $X$, which is not possible ...........+1 – DanielWainfleet Sep 18 '18 at 19:24