My question concerns the cohomology groups $H^k(RP^n,\mathbb{Z}_2)$. We know that $H_k(RP^n,\mathbb{Z}_2) = \mathbb{Z}_2$ if $0 \leq k \leq n$ and is trivial otherwise. I looked up the solution and it says that $H^k(RP^n,\mathbb{Z}_2) = \mathbb{Z}_2$ also when $0 \leq k \leq n$ and is trivial otherwise.
But we have $Ext(H_{k-1}(RP^n,\mathbb{Z}_2), \mathbb{Z}_2) = Ext(\mathbb{Z}_2, \mathbb{Z}_2) = \mathbb{Z}_2$ for $1 \leq k \leq n+1$ and $Hom(H_{k}(RP^n,\mathbb{Z}_2), \mathbb{Z}_2) = Hom(\mathbb{Z}_2, \mathbb{Z}_2) = \mathbb{Z}_2$ for $0 \leq k \leq n$. So for $1 \leq k \leq n$ we should have $H^k (RP^n,\mathbb{Z}_2) = \mathbb{Z}_2 \oplus \mathbb{Z}_2$ by the universal coefficient theorem. What is wrong with this calculation?
Have a look at the statement of the universal coefficient theorem, and pay attention to the difference between $R$ and $G$, $$ 0 \to \operatorname{Ext}_R^1(\operatorname{H}_{k-1}(X; R), G) \to H^k(X; G) \to \operatorname{Hom}_R(H_k(X; R), G)\to 0. $$
In the context of your question, $G = \Bbb Z_2$ and there are two ways to apply the universal coefficient theorem:
Over the field $R = \Bbb Z_2$
In this case, the $\operatorname{Ext}$ term is $\operatorname{Ext}_\Bbb{Z_2}^1(H_{k-1}(\Bbb R P^n, \Bbb Z_2), \Bbb Z_2)$. Since $\Bbb Z_2$ is free over $\Bbb Z_2$ (or more generally since $\Bbb Z_2$ is a field), the $\operatorname{Ext}$ term is trivial.
Over the PID $R = \Bbb Z$ and $\Bbb Z$-module $G = \Bbb Z_2$
In this case, the $\operatorname{Ext}$ term is $\operatorname{Ext}_\Bbb Z^1(H_{k-1}(\Bbb R P^n, \Bbb Z), \Bbb Z_2)$ and the $\operatorname{Hom}$ term is $\operatorname{Hom}_\Bbb Z(H_k(\Bbb R P^n, \Bbb Z), \Bbb Z_2)$. I'll let you work out the details, but you will get the same result.