Topological space where continuous functions to itself are exactly the constant functions and the identity In any topological space $X$, the identity function on $X$ and any constant function $X\rightarrow X$ are necessarily continuous. Does there exist an infinite topological space such that these functions are the only continuous functions $X\rightarrow X$?
I require the space to be infinite since there are finite examples such as the one-point space, and the space $\{1,2\}$ with open sets $\{\emptyset,\{1\},\{1,2\}\}$. Although I am not aware of any finite examples with more than two points, so those could be of interest to me too.
The only further progress I've made is that such a space must be connected: otherwise write $X$ as a disjoint union of nonempty open sets $U\cup V$. A map sending $U$ to one point and $V$ to a different point is then continuous.
 A: Yes, there exist such spaces, they can even be very nice! In 1967 Cook constructed a compact metric connected space, now known as the Cook continuum which has exactly the property you're asking for.
A: About your second question: 
Let $X$ be a finite space with this property. Then $X$ has at most 2 elements:
Assume $|X| \ge 3$.
$X$ is T0 [Assume not, then there are distinct $x, y \in X$ such that $x \in \overline{\{y\}}$ and $y \in \overline{\{x\}}$. It is easy to see that the transposition $\tau_{x,y}$ which exchanges $x$ and $y$ and leaves every other element untouched, is a homeomorphism.]
Since $X$ is finite, there is a partial order $\le$ on $X$, such that the open sets are exactly the upper bounds of $X$ with respect to $\le$.
There exist $a, b, c \in X$ such that $b < c$ and  $b \nleq a$.  
[If X contains a chain of at least three elements, we are done. Since X is not discrete, there exist $b, c \in X$ with $b < c$. If $b$ is not the minimum of $X$, we are done. So let $b=$ min $(X)$, all other elements incomparable. Pick $d \in X \setminus \{b, c\}$. Then it is easy to see that the transposition $\tau_{c,d}$ is a homeomorphism.This proves the claim.]
Now define 
$f: X \rightarrow X, f(x) := 
\left\{ \begin{array}{c@{,  }l}
              x,   & b \le x      \\
              b,   & b \nleq x
           \end{array}   \right.$
It is easy to see that f is increasing, hence continuous.
Moreover, $f(a) = b$, $f(c) = c \neq b$.
Hence $f$ is neither the identity map, nor constant. Contradicition!
