# help with using etoolbox with docsvlist and listadd

I am looking at etoolbox and not able to find why it gives this error. I am going over an example in the manual, which works. But when I made small change, I am getting an error.

This works:

\documentclass[10pt]{book}
\usepackage{etoolbox}
\begin{document}
\begin{enumerate}
\renewcommand*{\do}[1]{\item #1}
\docsvlist{{item1, 1},{item2, 2},{item3, 3}}
\end{enumerate}
\end{document}


But the above example has the list right there inline. I wanted to first create the list outside, and then process it separately. I found the command listadd

So used it to make a list and then run the \begin{enumerate} on the list, I get an error:

\documentclass[10pt]{book}
\usepackage{etoolbox}
\begin{document}
\begin{enumerate}
\renewcommand*{\do}[1]{\item #1}
\docsvlist{\mylist}
\end{enumerate}
\end{document}


Error is

    Command \end{enumerate} invalid in math mode. \end{enumerate}


Here is the example I was trying

Question is: How can one create a list using listadd and process it separately using \docsvlist{\mylist} ?

You have to use \dolistloop to loop over the element of \mylist, not \docsvlist. After you create it, \mylist is an internal list and no longer a comma separated list. The manual specifies that
The character | with category code 3. Note that you may not typeset a list by saying \listname. Use \show instead to inspect the list.