search in a list??

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


jubafre at 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]


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

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

More information about the Python-list mailing list