Have I missed something, or wouldn't this work just as well:<br><br><span style="font-family: courier new,monospace;">>>> list_of_strings = ['2', 'awes', '3465sdg', 'dbsdf', 'asdgas']<br>

>>> [word for word in list_of_strings if word[0] == 'a']<br>['awes', 'asdgas']</span><br><br>Cheers,<br>Xav<br>
<br><br><div class="gmail_quote">On Mon, May 10, 2010 at 6:40 PM, Jimbo <span dir="ltr"><<a href="mailto:nilly16@yahoo.com">nilly16@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Hello<br>
<br>
I am trying to find if there is a string OR list function that will<br>
search a list of strings for all the strings that start with 'a' &<br>
return a new list containing all the strings that started with 'a'.<br>
<br>
I have had a search of Python site & I could not find what I am<br>
looking for, does a function like this exist?<br>
<br>
The only one that I think could work is, use the string<br>
function .count()<br>
<br>
algorithm: to exract all the words inside a list that start with 'a'<br>
 - make sure the list is arranged in alphabetical order<br>
 - convert the list to a big string<br>
 - use list_string.count(',a') to obtain the index where the last 'a'<br>
word occurs<br>
 - convert back into string (yes this is a REAL hack :P)<br>
 - and then create a new list, ie, new_list = list[0:32]<br>
 - & return new_list<br>
<br>
Ok that algorithm is terrible, I know, & I just realise that it wont<br>
work for letters after 'a'. So if anyone could suggest a function or<br>
algorithm it would be extremely helpful<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>