List problem

Thomas Bach thbach at students.uni-mainz.de
Sun Dec 2 10:59:22 EST 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