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>Try a list comprehension: </p>

<pre><code>just_floats = [i for i in your_list.split(',') if i.count('.') == 1]
</code></pre>

<p>first you split the string where the commas are, then you filter through the string and get rid of values that don't have a decimal place</p>

python string