List problem

Thomas Bach thbach at students.uni-mainz.de
Sun Dec 2 16:59:22 CET 2012


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.



More information about the Python-list mailing list