<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
I'd like to know how to elegantly check a list for the membership of<br>
any of its items to another list.  Not caring for elegance, I would<br>
use the following code:<br>
</blockquote><div><br>That's one of the useful properties of sets:<br><br>>>> a = [1,2,3]<br>>>> b = [3,4,5,6]<br>>>> set(a) & set(b)<br>set([3])<br>>>> set(a).intersection(b)<br>set([3])<br>
<br>That's two spellings of the same thing. As for testing: an empty set like an empty list will return false, so "if set(a) & set(b):" will be true or false based on if there's any commonalities between the two lists.<br><br>--Stephen</div></div><br>