Try to search your question here, if you can't find : Ask Any Question Now ?

TypeError: descriptor 'append' requires a 'list' object but received a 'numpy.float64'

HomeCategory: stackoverflowTypeError: descriptor 'append' requires a 'list' object but received a 'numpy.float64'
bhawya asked 2 weeks ago

can somebody help me? I don’t understand how to fix the error in this case. I’ve already tried with numpy array, but the problem still presents.
What I’m trying to do is: to calculate the runge function with the x for n iterations. For making this, I think that I have do put every single x in a list, and I do this with the fill_cheby function. After this, I want to use the numbers in list1 as arguments of lagrange function in runge_interpolate. Here the code and the complete traceback:

 def fill_cheby(list1,n,x):
    if n==0:
        return n, x
    else:
        for i in range(0,n):
            x=np.cos(((2*(n-i)+1)*3.14)/(2*(n+1)))
            list1.append(x)

        return list1

def runge_interpolate(n):

    p=lagrange(list1, runge(x))
    print("Il polinomio รจ ", p)
    return x, p

list1=[]

n=5
x=0
fill_cheby(list1,n,x)

Traceback (most recent call last):
File “arraycheby.py”, line 33, in
fill_cheby(list,n,x)
File “arraycheby.py”, line 19, in fill_cheby
list1.append(x)
TypeError: descriptor ‘append’ requires a ‘list’ object but received a ‘numpy.float64’

1 Answers
Best Answer
Arben answered 2 weeks ago
Your Answer

5 + 5 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com