TITLE: Contractible spaces has trivial fundamental group.
QUESTION [12 upvotes]: I have to prove the following: Show that if $X$ is contractible (the def. I have is that $I:X\rightarrow X$ the identity function is homotopic to the constant function $p$ for some $p\in X$), then its fundamental group is trivial. 
Here is my attempt: Since the space is contractible, it is path connected (every point will be contracted to a fixed point, then for any two arbitrary, take the path to the fixed point, and then walk backwards on the other path, this gives you a path between any two points), I can assume that $\pi_1(X,p)$ is such that $p$ is the contraction point (since in a path connected space, all the groups obtained at different origins are isomorphic), then, let $h$ be my homotopy between the identity and the constant map, so we have: 
$$
h(0,-)=I(-)
$$
$$
h(1,-)=p
$$were $I$ is the identity on $X$ and $p$ is the constant path. Let $\gamma\in \pi(X,p)$. I want to show $[\gamma]=[p]$, so I thought of this homotopy, $F:[0,1]^2\rightarrow X$ via: 
$$
F(t,s)=h(t,\gamma(s))
$$Then, $F(0,s)=h(0,\gamma(s))=I(\gamma(s))=\gamma(s)$, $F(1,s)=p$, and lastly $F(t,0)=F(t,1)=h(t,\gamma(0))=h(t,p)$. I do not know how to argue why $h(t,p)=p$ for a contraction to $p$. It might be that my $F$ is incorrect too. (Note that $F$ is clearly cts, since $h$ is and $\gamma$ is as well).

REPLY [2 votes]: If your space X is contractible by hypothesis then you have an homotopy equivalence between X and $\lbrace x_0 \rbrace $ (the space with only one point). Then it is not difficult to prove that the homotopy equivalence induce an isomorphism between the 2 fundamental groups.
maybe you are not "allowed" to use these results but according to me the best way to solve this kind of exercise is to find an easier homotopically equivalent space and work with it. About this, using CW structure and theorems can be very helpful.
if you need to show an explicit homotopy the other answer is good. This is just an example of another approach.