[Array] Finding index that contains part of a string?

Gilles Ganault nospam at nospam.com
Wed Nov 12 08:47:55 EST 2008


Hello

Out of curiosity, is there a better way in Python to iterate through
an array, and return the index of each item that contains the bit
somewhere in its value, ie. index() doesn't work because it only
returns if the value only contains the item I'm looking for.

This works:
========
next = re.compile(">&#9658<")
i = 0
for item in items:
	m = next.search(item)
	if m:
		print "Found Next in item %s" % i
	i = i + 1
========

Thank you.



More information about the Python-list mailing list