partial / wildcard string match in 'in' and 'list.index()'

Jon Perez jbperez808 at wahoo.com
Fri May 28 00:41:28 EDT 2004


For a given list:

fruits=["apples","oranges","mangoes","bananas"]




Is it possible to do wildcard matches like shown below?

1. "man*" in fruits

2. fruits.index("man*")

3. "*nanas*" in fruits

4. fruits.index("*nanas")



or is there any way to achieve an equivalent effect
short of doing a while loop?



More information about the Python-list mailing list