 <p>Here's a similar approach, using regular expressions instead:</p> <pre><code>import re def convert_string(s): return map(int, re.findall(r'[0-9]+', s)) </code></pre> <p>Or using a list comprehension:</p> <pre><code>import re def convert_string(s): return [int(num) for num in re.findall(r'[0-9]+', s)] </code></pre> <p>This is a more general approach and will work for any character (in this case '|') that separates the numbers in the input string.</p>