ValueError: could not convert string to float: '[231.49377550490459]'
<p>I am trying to cast a python list into a float. 
This is the problem narrowed down:</p>

<pre><code>loss = ['[228.55112815111235]', '[249.41649450361379]']
print(float(loss[0]))
</code></pre>

<p>And results in the error:</p>

<pre><code>ValueError: could not convert string to float: '[231.49377550490459]'
</code></pre>

<p>Can anyone help me?</p>

<p>You can use string slicing if there is always just one element in your string list.</p>

<pre><code>loss = ['[228.55112815111235]', '[249.41649450361379]']
print(float(loss[0][1:-1]))
</code></pre>

python