Nullhomotopic Mappings and Contractible Spaces

I am having problems proving this fact. A space X is contractible if and only if
every map f:X to Y (Y is arbitrary) is nullhomotopic. Similarly show X is contractible
iff ever map f:Y to X is nullhomotopic.

In the first case if Y=X then see that the identity map on X is nullhomotopic. But Im not
sure how to proceed for the rest.

© SolutionLibrary Inc. solutionlibary.com 9836dcf9d7 https://solutionlibrary.com/math/geometry-and-topology/nullhomotopic-mappings-and-contractible-spaces-3e6g