TITLE: $X$ is contractible and $Y$ is path connected then $[X,Y]$ has a single point
QUESTION [6 upvotes]: Im trying to show that: 
for $X,Y$ topological spaces
$X$ is contractible and $Y$ is path connected then $[X,Y]$ has a single point 
while $[X,Y]$ denote the set of homotopy classes of maps of $X$ into $Y$.
i tried to use that $Id_X \sim x_0$ by the homotopy $F:X\times I \to Y$ (while $I=[0,1]$)
and let $f\in [X,Y]$ so $f\circ F$ will give us a homotopy of $f$ and the constant function $f(x_0)$ 
but i dont understand how to show it for a fixed point $y_0$ in $Y$. i imagine it involves a path from  $y_0$ to $f(x_0)$

REPLY [3 votes]: Although Najib Idrissi already answered your question, I think you could use the following to really understand what it is going on. In such an exercise, it is generally not a good idea to dive into a ad hoc resolution where you don't see the highlights. I think it can benefit you to search for 1 or 2 more general lemma(s) and then apply them to your problem.
As follow.

Lemma 1. If $X$ and $X'$ are homotopy equivalent, then for every topological space $Y$, there is a bijection $ [X,Y] \simeq [X',Y]$.

Hint for the proof. A continuous application $f \colon X \to X'$ induces a function $[X',Y] \to [X,Y]$ (how?). For $f$ an homotopy equivalence, show that the induced function is a bijection.

Lemma 2. Denotes $\pi_0(Y)$ for the set of path-connected components of a topological space $Y$, and $\ast$ for the topological singleton. There is a bijection $[\ast, Y] \simeq \pi_0(Y)$.

Hint for the proof. There is a fairly obvious identification of maps $\ast \to Y$ as points of $Y$. Homotopies between points are then just paths.

Application. Apply lemma 1 for the homotopy equivalence between $X \to \ast$. Apply then lemma 2 with your $Y$ (for which $\pi_0(Y)$ is a singleton).