Proof that $X$ contractible $\iff \forall f:X \rightarrow Y$ : $f \cong const.$

I'm reading Hatcher and I did exercise 10 on page 19. Can you tell me if my answer is correct? Many thanks for your help!

Claim: $X$ contractible $\Leftrightarrow \forall$ arbitrary maps $f:X \rightarrow Y$, $Y$ arbitrary, $f \cong const.$

Proof:

$\implies$

Given the homotopy $H: I \times X \rightarrow X$, $H(0,x) = id_X$, $H(1,x) = id_{ \{ \ast \}}$ and an arbitrary map $f: X  \rightarrow Y$ construct a homotopy $H^\prime: I \times X \rightarrow Y$, $H^\prime(0,x) = f(x)$, $H^\prime(1,x)=const_{y_0 \in Y}$ as follows:

$H^\prime (t,x) := f(H(t,x))$.

Note that even though not stated in the exercise, $f$ is assumed to be continuous. (At least I think that's the case)

$\impliedby$

Given $\forall f:X \rightarrow Y$: $f \cong const.$ we pick $Y := X$ then $f:X \rightarrow X$ $\cong const_{x_0} \forall f$. Now pick $f := id_X$.

Second part of question:

Claim: $X$ contractible $\iff \forall f: Y \rightarrow X$: $f \cong const_X$

Proof:

$\implies$

Define $H^\prime(t,x) := H(t, f(x))$.

$\impliedby$

Choose $Y:=X$ and $f:=id_X$.


This looks basically right, although to nitpick I might argue that you should either write that $H(0,-)=id_X$ and $H(1,-)=const._*$ (both as maps $X\rightarrow X$) or you should write that $H(0,x)=x$ and $H(1,x)=*$ for all $x\in X$.

Also, I think I can confidently say that you can assume every map in any topology book is assumed to be continuous. Similarly, any function of groups can generally be assumed to be a homomorphism, etc. The fancy way of saying this here is that we're working in the category of topological spaces, whose morphisms are continuous maps.