Python newbie here. I am trying to operate on lists which contain floating point numbers. avg 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. avg1 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.
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
The error that I get is as follows :
avg1 = [float(i) for i in avg]
TypeError: float() argument must be a string or a number, not 'list'
Using Python 3.4
avglooks like. Seems as if it is a list of lists or sth alike.float(i[0])if it's always in this shape.