search for pattern in StringList

Moshe Zadka moshez at
Tue Dec 19 05:01:09 CET 2000

On Mon, 18 Dec 2000, Simon Brunning <SBrunning at> wrote:
> myList = ['an', 'been', 'call', 'door']
> for i in range(0, len(myList)):
>     if myList[1].find('a') <> -1:
>         print i, myList[i]

Why not
for (i, element) in zip(range(myList), myList):
	if 'a' in element:
		print i, element
(Warning: zip was added in Python 2.0)
Moshe Zadka <sig at>
This is a signature anti-virus. 
Please stop the spread of signature viruses!

More information about the Python-list mailing list