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

Jon Perez jbperez808 at wahoo.com
Fri May 28 06:41:28 CEST 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