wildcard match with list.index()
gstaniak at wp.pl
Mon Nov 10 18:30:04 CET 2008
On 10.11.2008, Mr.SpOOn <mr.spoon21 at gmail.com> wroted:
> is there any way to search elements in a list using wildcards?
> I have a list of various elements and I need to search for elements
> starting with 'no', extract them and put in a new list.
> I was thinking about something like:
> Of course this doesn't work.
I guess there's a way to use the glob module in this situation, but
for the specific case I think you can use:
start_with_no = (i for i in mylist if i.startswith("no"))
Grzegorz Staniak <gstaniak _at_ wp [dot] pl>
Nocturnal Infiltration and Accurate Killing
More information about the Python-list