Number of homotopy classes 
For topological spaces $X$ and $Y$, let $[X,Y]$ denote the set of homotopy classes of continuous maps $X\to Y$.

*

*If $I=[0,1]$ is the unit interval, then $[X,I]$ has only one element.

*If $X$ is path connected, then $[I,X]$ has only one element.


I am new to these topics and have no clue where to start yet. Could anyone at least give me a clue to follow?
For the sake of context, this is Exercise 2 from Section 51 (Chapter 9) of Munkres' Topology .
 A: Hint
a) $[X,Y]$ has only one element if $Y$ is contractible (sufficient not necessary). Show first that this statement is true and then that $I$ is contractible.
b) First show directly that every map $f:I\to X$ is homotopic to the constant map with value $f(0)$. Then use path connectedness to show that any two of these constant maps are homotopic.
A: If you want to prove that $[X,Y]$ has only one element, you have to show that any two continuous maps $f,g:X\to Y$ are homotopic. To show that two maps are homotopic, you have to find a homotopy between them, i.e. a continuous map $F:X\times I\to Y$ such that $F(x,0)=f(x)$ and $F(x,1)=g(x)$ for all $x\in X$.
A: Note that the inclusion $i:\{0\}\hookrightarrow I$ is a homotopy equivalence whose inverse is the retraction $r:X\twoheadrightarrow\{0\}$.
Each homotopy $F_t:f\simeq g:I\to Y$ can then be composed with $i$ to a homotopy $fi≃ gi$. Conversely, a homotopy $G_t:k≃l:\{0\}→ Y$ can be composed with $r$ and then gives a homotopy $kr≃lr:I→Y$. This means that the assignments $f↦fi$ and $k↦kr$ respect homotopies.
Now let $H$ be the homotopy $1_I≃ir$. This gives rise to a homotopy $fH:f≃fir$. On the other hand, we have $kri=k:\{0\}→Y$. This means that $f$ and $fir$ are in the same class, as well as $k$ and $kri$. Therefore the maps
$$i^*:[I,Y]→[\{0\},Y],\ f\mapsto fi$$
and $$r^*:[\{0\},Y]→[I,Y],\ k↦kr$$ are inverse to each other.
This tells us that we could as well replace $I$ by the singleton $\{0\}$ and simply look at $[\{0\},Y]$ which is the set of path-components of $Y$.
The same argument gives a bijection $[X,I]≃[X,\{0\}]$. This implies that $[X,I]$ has only one element.
