Python: Extract multiple float numbers from string
<p>Forgive me, I'm new to Python.</p>

<p>Given a string that starts with a float of indeterminate length and ends with the same, how can I extract both of them into an array, or if there is just one float, just the one.</p>

<p>Example: </p>

<pre><code>"38.00,SALE ,15.20"
"69.99"
</code></pre>

<p>I'd like to return:</p>

<pre><code>[38.00, 15.20]
[69.99]
</code></pre>

<p>Split the input, check if each element is numeric when the period is removed, convert to float if it is.</p>

<pre><code>def to_float(input):
    return [float(x) for x in input.split(",") if unicode(x).replace(".", "").isdecimal()]
</code></pre>

python string