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).