search in a list??

Christophe Delord christophe.delord at free.fr
Mon Aug 19 14:51:13 EDT 2002


You can use lists or the filter function. For example:

>>> x=['LDA', 'D1', 'ADD', 'D2', 'STA', 'D3', 'HLT', 'D1:', 'DB', '3', 'D2:', 'DB', '2', 'D3:', 'DB', '0']
>>> [ e for e in x if ':' in e ]
['D1:', 'D2:', 'D3:']
>>> filter(lambda e: ':' in e, x)
['D1:', 'D2:', 'D3:']
>>>


On Mon, 19 Aug 2002 15:23:58 -0300 (GMT-03:00)
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?????
> 
> for example:
>  
> the node 7 -> "D1:" have de two points, but i don´t know how to get this information.
> 	
> Juliano Freitas
> www.gebrasil.hpg.com.br 
> 


-- 

(o_   Christophe Delord                   _o)
//\   http://christophe.delord.free.fr/   /\\
V_/_  mailto:christophe.delord at free.fr   _\_V



More information about the Python-list mailing list