Weak homotopy equivalence induces isomorpism of sets of homotopy classes?

There is a question in my homework on the algebraic topology course asking if two spaces $$X$$ and $$Y$$ are weakly homotopy equivalent in case for every cellular space $$Z$$ sets $$[Z,X]$$ and $$[Z,Y]$$ are naturally bijective.

I'm wondering if converse statement holds at least for cell complexes. Suppose $$f\colon K\to K'$$ is weak homotopy equivalence of cell complexes $$K,K'$$, namely, $$f_*\colon \pi_i(K)\to \pi_i(K')$$ is isomorphism for all $$i$$. I need to show that $$f_*\colon [X,K]\to [X,K']$$ is bijection.

First I tried to show that it is injective. Suppose $$f_*[\alpha]=f_*[\beta]$$ for some maps $$\alpha,\beta\colon X\to K$$. I want to prove that $$\alpha\simeq \beta$$ then. As soon as $$f\circ\alpha\simeq f\circ\beta$$, then for every spheroid $$\varphi\colon S^k\to X$$ $$f\circ(\alpha\circ\varphi)\simeq f\circ(\beta \circ\varphi)$$, and thus $$\alpha\circ\varphi\simeq \beta \circ\varphi$$, because $$f_*$$ is bijection between $$\pi_k(K)=[S^k,K]$$ and $$\pi_k(K')=[S^k,K']$$.

Suppose $$\varphi\colon S^k\to X$$ is attaching map for the cell $$e^k$$ in $$X$$. I have homotopy $$H:S^k\times [0,1]\to K$$, $$H|_{t=0}=\alpha\circ\varphi$$, $$H|_{t=1}=\beta\circ\varphi$$ I wish I could extend on the whole cell. Indeed, I can use HEP in this case for the homotopy $$H$$ and map $$\alpha|_{D^k}\colon D^k\to K$$ and hence I have homotopy $$\tilde H\colon e^k\times [0,1]\to K$$ between $$\alpha$$ and $$\beta$$.

However, there is a problem, because these homotopies are not necessarily agreed. How do I deal with that?

• Oh my gosh, I've just realized that, in fact, all this time I've been trying to prove Whitehead's theorem – igortsts Dec 12 '18 at 16:58