It is needed to insert a Minted inside Xsim environment. The basic code is as follow:
\documentclass{book}
\usepackage{xcolor}
\usepackage{minted}
\usepackage[verbose]{xsim}%paquete de ejercicios mejorado
\usepackage{musixtex}
\begin{document}
\chapter{Chapter One}
Chapter one.
\begin{exercise}
Exercise description.
\end{exercise}
\begin{solution}
Solution:
\begin{minted}{python}
def serie_armonica(fundamental, limite):
p1 = pitch.Pitch(fundamental)
serie_armonica("C2", 16)
\end{minted}
\end{solution}
\printsolutionstype[chapter=1]{exercise}
\chapter{Chapter Two}
Chapter two.
\end{document}
By some reason, the line: \printsolutionstype[chapter=1]{exercise} prompts an error: LaTeX Error: \begin{document} ended by \end{minted}.