List problem

subhabangalore at gmail.com subhabangalore at gmail.com
Sun Dec 2 11:10:10 EST 2012


On Sunday, December 2, 2012 9:29:22 PM UTC+5:30, Thomas Bach wrote:
> On Sun, Dec 02, 2012 at 04:16:01PM +0100, Lutz Horn wrote:
> 
> > 
> 
> > len([x for x in l if x[1] == 'VBD'])
> 
> > 
> 
> 
> 
> Another way is
> 
> 
> 
> sum(1 for x in l if x[1] == 'VBD')
> 
> 
> 
> which saves the list creation.
> 
> 
> 
> Regards,
> 
> 	Thomas.

Thanks. After I posted I got a solution as,
[x for x, y in enumerate(chunk_word) if "/VB" in y]
but you are smarter.
Thanks.
Regards,
Subhabrata. 



More information about the Python-list mailing list