Example of finite fundamental group I recently did the following exercise:

$X$ is a path-connected space and $\pi_1(X)$ is finite. $h:X\to S^1$ is a continuous map. Prove that $h$ is null-homotopic.

I am wondering about this:  what are some interesting examples of $X$? I cannot find any space with non-trivial finite fundamental group. How can I construct one? I want to know some examples of $X$ that are not contractible where this theorem applies.
 A: Here's a general construction:

Let $G$ be a group, given by the presentation $\langle g_\alpha\ |\ r_\beta \rangle$ where $\alpha$ and $\beta$ range over sets $A$ and $B$ respectively. Begin by forming the wedge product $S = \vee_{\alpha \in A} S^1$ which has fundamental group $*_\alpha \langle g_\alpha \rangle$, where '$*$' denotes the free product of groups. Then for each $\beta$ choose a map $f_\beta\colon S^1 \to S$ which represents the word $r_\beta$, and form $X$ by attaching a copy of $D^2$ to $S$ using $f_\beta$ for each $\beta\in B$.

Claim: $\pi_1(X) \cong G$.
Now to answer your question, just take any finite $G$. For a nice example, work out the construction where $G$ has a single generator, i.e. is cyclic.
(It's worth pointing out that with a little more work you can prove that actually every finitely presented group is the fundamental group of some compact $4$-manifold.)

For examples of $X$ that are not contractible, note that if $\pi_1(X) \neq 0$ then certainly $X$ is not contractible, so my above construction provides examples. Moreover if $\pi_1(X) = 0$ but some higher homotopy group is non-zero then it will still be not contractible. For example if $n>1$ then $\pi_1(S^n) = 0$ so the exercise you did verifies that any continuous map $S^n \to S^1$ is nullhomotopic for $n>1$, or in other words $\pi_n (S^1) = 0$ in this range, but still $\pi_n(S^n) \cong \mathbb{Z}$ so it is not contractible. There are many other examples of spaces where $\pi_1(X) = 0$ but $X$ is not contractible, even spaces where all of the homotopy groups vanish (for example the Warsaw Circle).
