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>You can try something like</p>

<pre><code>the_string = "38.00,SALE ,15.20"
floats = []
for possible_float in the_string.split(','):
    try:
        floats.append (float (possible_float.strip())
    except:
        pass
print floats
</code></pre>

python string