Using wild character

Diez B. Roggisch deets at nospam.web.de
Thu Sep 6 09:21:08 CEST 2007


Sreeraj schrieb:
> hi,
> 
>  I am a beginner in Python. I wish to know how can i filter a list of
> strings using wild characters.ie
> Lets say i have list countries =
> ["india","africa","atlanta","artica","nigeria"]. I need only the list
> of string starting with 'a'.

While the startswith-method others pointed out works, I wanted to direct 
you attention to the module fnmatch.

http://www.python.org/doc/current/lib/module-fnmatch.html

It will work with real wildcards.

Diez



More information about the Python-list mailing list