My problem is that I can set up toggles, using etoolbox's \newtoggle{x}, set it to true with \toggletrue{x} and even use it with iftoggle{x}{this for true}{this for false}. However, if I try to put a verbatim environment inside a conditional block, it breaks and gives me an error message:
Runaway argument?
for x in range(1, 43): print('x=', x) \end {verbatim}
./q4.tex:19: Paragraph ended before \@xverbatim was complete.
<to be read again> )
./Quiz1.tex:90: Missing number, treated as zero.
<to be read again>
{
l.90 \vspace{
1 pc}
?
\par
l.19 }{}
?
for the code:
\iftoggle{displaysolutions}{
\textit{The statement will execute y times.}
\begin{verbatim}
for x in range(0, y):
print('x=', x)
\end{verbatim}
}{}
Any ideas of what I'm possibly doing wrong? Any alternatives?

