[Python 2.7.3] What's the difference between these two uses of "for"?

Terry Reedy tjreedy at udel.edu
Mon Mar 18 00:37:50 EDT 2013


On 3/17/2013 8:58 PM, Yves S. Garret wrote:
> N00b question.  But here is the code:
>
> http://bin.cakephp.org/view/709201806

Short code like this should be included in your message.

tricky = sorted([w for w in set(text2) if 'cie' in w or 'cei' in w])
for word in tricky:
   print word,

for word in sorted([w for w in set(text2) if 'cie' in w or 'cei' in w]):
   print word,

-- 
Terry Jan Reedy




More information about the Python-list mailing list