messy/overwritten numbering in enumerate tag

I have the following in my LateX code:

\begin{enumerate}
\item
\begin{lstlisting}
x = [x for x in xrange(4, 9)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}


Now, the result I get overlaps/overwrites positions for the numberings:

This obviously, not what anyone would want to do. How can I fix the numbering?

Thanks for all the help?

-
Depending on your application, I would consider using \lstinline instead... Might I ask what you're trying to get at? (Just out of curiosity.) –  Sean Allred Feb 1 at 5:59

Leave a blank line (or use \par):

\documentclass{article}
\usepackage{listings}

\begin{document}

\begin{enumerate}
\item
\begin{lstlisting}
x = [x for x in xrange(4, 9)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\end{enumerate}

\end{document}


Or use \lstinline:

\documentclass{article}
\usepackage{listings}

\begin{document}

\begin{enumerate}
\item
\lstinline{x = [x for x in xrange(4, 9)]}
\item
\lstinline{x = [x for x in xrange(6)]}
\item
\lstinline{x = [x for x in xrange(6)]}
\end{enumerate}

\end{document}


-
Is there a TeX command line where I could use a help interface? For example, could I do help(par)? –  CodeKingPlusPlus Feb 1 at 1:49
@codeking You can use the command texdoc but that is mostly for packages. –  Kartik Feb 1 at 2:12
@CodeKingPlusPlus there's \show that gives the "definition" of commands, but since \par is a TeX primitive, it won't help here. \par end the paragraph; it is equivalent to leaving a blank line in the code. –  Gonzalo Medina Feb 1 at 2:15