search in a list??

Thomas Jensen spam at ob_scure.dk
Mon Aug 19 21:03:22 CEST 2002


Hello

jubafre at brturbo.com wrote:
> i have a list:
> x=['LDA', 'D1', 'ADD', 'D2', 'STA', 'D3', 'HLT', 'D1:', 'DB', '3', 'D2:', 'DB', '2', 'D3:', 'DB', '0']
> 
> i want to indentify de nodes with ":", how i can get this?????

Well you could use list comprehensions:

    [item for item in x if item.find(':') >= 0]

prints:

   ['D1:', 'D2:', 'D3:']


-- 
Best Regards
Thomas Jensen
(remove underscore in email address to mail me)




More information about the Python-list mailing list