[Tex/LaTex] Figure numbering with minipages (memoir)

captionsmemoirminipagenumbering

I have the following figure, where I can't seem to get the numbering right.
The numbers next to the captions comes out as Figure 1, Figure 2, and Figure 3, but I want them to be (a), (b), and Figure 1

\begin{figure}[!h]
\centering
\begin{minipage}{0.45\linewidth}

\begin{python}
  for i in [1,2,3,4]:
    print i
\end{python}
\caption{Implementation in Python}

\end{minipage}
\qquad
\begin{minipage}{0.45\linewidth}

\begin{python}
  1
  2
  3
  4 
\end{python}
\caption{Output}

\end{minipage}

\caption{Python code}
\label{lst:python_code}
\end{figure}

I am using the memoir class. Including the minipages in subfigures yields an error from pygmentize.

Best Answer

Use \newsubfloat{figure} and then \subcaption

\documentclass{memoir}
\newsubfloat{figure}

\begin{document}

\begin{figure}
\centering
\begin{minipage}{0.45\linewidth}
contents...
\subcaption{Implementation in Python}
\end{minipage}\hfill
\begin{minipage}{0.45\linewidth}
contents...
\subcaption{Output}
\end{minipage}
\caption{Python code}
\label{lst:python_code}
\end{figure}

\end{document}