At Friday 5/1/2007 17:39, [EMAIL PROTECTED] wrote:

wordfreq = [wordlist.count(p) for p in wordlist]

I would expect

for p in wordlist:
    wordfreq.append(wordlist.count(p))


I didn't know you could have an expression in the same line.

That's known as a "list comprehension" and is roughly equivalent to your code. Section 5 of the tutorial covers them. http://docs.python.org/tut/node7.html


--
Gabriel Genellina
Softlab SRL

        

        
                
__________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to