extract elements of n char from a list

Shagshag13 shagshag13 at yahoo.fr
Fri Jul 26 07:42:14 EDT 2002


hello,

i want to efficiently extract elements of n char from a list :

n = 2
l = ['this', 'is', 'an', 'example']
nl = []
for i in l:
    if len(i) == n:
        nl.append(i)

nl = ['is', 'an']

but i think that some clever guru could use a map() / reduce() or something like that to speed up the process (which is what i
really need...)

thanks for your help,

s13.





More information about the Python-list mailing list