# Listings package not working properly with Exam class

When I gave my code in the exam class like

\begin{parts}
\part \begin{lstlisting}
echo The date is $date \end{lstlisting} \part \begin{lstlisting} echo The date is$(date)
\end{lstlisting}
\end{parts}


I want is the line starting with echo in (a) and (b) respectively. Instead that only \part displays only (a)

-
Add a blank line or a \par between \end{lstlisting} and \part. – clemens Mar 6 '13 at 8:20

Putting it in \lstinline solved my problem
\begin{parts}
\part \lstinline{echo The date is $date} \part \lstinline{echo The date is$(date)}