Solution (source code)

= Solution

Electromagnetism gauges the vector flavour transformation $U\mapsto e^{ie\alpha Q}Ue^{-ie\alpha Q}$, so covariance requires $D_\mu U=\partial_\mu U-ieA_\mu[Q,U]$. The identity part of $Q=I/6+\sigma_3/2$ drops out of the commutator. Writing
$$
\pi=\begin{pmatrix}\pi^0/2&\pi^+/\sqrt2\\\pi^-/\sqrt2&-\pi^0/2\end{pmatrix}
$$
gives $[Q,\pi]_{12}=\pi_{12}$ and $[Q,\pi]_{21}=-\pi_{21}$. Hence $\pi^+$ has electric charge $+e$, $\pi^-$ has charge $-e$, and $\pi^0$ is neutral.