How to return a subset of a list that matches a condition
<p>Let's say I have a list of <code>int</code>s:</p>

<pre><code>listOfNumbers = range(100)
</code></pre>

<p>And I want to return a list of the elements that meet a certain condition, say:</p>

<pre><code>def meetsCondition(element):
    return bool(element != 0 and element % 7 == 0)
</code></pre>

<p>What's a Pythonic way to return a sub-<code>list</code> of element in a <code>list</code> for which  <code>meetsCondition(element)</code> is <code>True</code>?</p>

<p>A naive approach:</p>

<pre><code>def subList(inputList):
    outputList = []

    for element in inputList:
        if meetsCondition(element):
            outputList.append(element)

    return outputList

divisibleBySeven = subList(listOfNumbers)
</code></pre>

<p>Is there a simple way to do this, perhaps with a list comprehension or <code>set()</code> functions, and without the temporary <code>outputList</code>?</p>