Python - TypeError: float() argument must be a string or a number, not 'list
<p>Python newbie here. I am trying to operate on lists which contain floating point numbers. <code>avg</code> is a list parameter that is returned from a different method. However, when I tried doing the following, it throws me an error that float() should have a string or a number and not a list. <code>avg1</code> should contain a copy of the lists with float-type numbers instead of lists right? I tried a few edits I read on other posts with similar titles, but couldn't solve this.
Just starting out so kindly tell me where I am going wrong. </p>

<pre><code>def movingavg(EMA,avg):     
    EMA=[]
    avg1 = [float(i) for i in avg]
    EMA[:3] = avg1[:3]
    for i,j in zip(EMA[2:],avg1[3:]):
        a =float(i)*0.67 + float(j)*0.33
        EMA.append(a)
    return EMA
</code></pre>

<p>The error that I get is as follows :</p>

<pre><code>avg1 = [float(i) for i in avg]
TypeError: float() argument must be a string or a number, not 'list'
</code></pre>

<p>Using Python 3.4</p>

<p>For example if you have list = [ [1,2],[4,5] ] 
then you can use 
[[float(s) for s in xs] for xs in list]
 and it's output is:
 [[1.0, 2.0], [4.0, 5.0]] </p>

python python-3.x