Show that a retract of a contractible space is contractible. This exercise come from the Hatcher' book.
This is my proof.
Since $X$ is contractible, there are maps $f: X\rightarrow x$ and $g:x\rightarrow X.$Such that $f\circ g=id, g\circ f=id.$ i.e. $X\simeq x$. Where $x$ is a point. Let $r: X\rightarrow A$ be the retract.
Then define $h:A\rightarrow x$. And then $h\circ r\circ g=id_x$, $r\circ g\circ h=id_A$.
Is this correct?