How to create a list from another list using specific criteria in Python?
<p>How can I create a list from another list using python?
If I have a list:</p>

<pre><code>input = ['a/b', 'g', 'c/d', 'h', 'e/f']
</code></pre>

<p>How can I create the list of only those letters that follow slash "/" i.e.</p>

<pre><code>desired_output = ['b','d','f']
</code></pre>

<p>A code would be very helpful.</p>

<p>With regex:</p>

<pre><code>&gt;&gt;&gt; from re import match
&gt;&gt;&gt; input = ['a/b', 'g', 'c/d', 'h', 'e/f', '/', 'a/']
&gt;&gt;&gt; [m.groups()[0] for m in (match(".*/([\w+]$)", item) for item in input) if m]
['b', 'd', 'f']
</code></pre>

python list