Skip to content Skip to sidebar Skip to footer

Python Error Only Length-1 Arrays Can Be Converted To Python Scalars

I am new to python coding and i am writing a code to calculate the sum of a series, i started by writing a function where the input is the number of iterations of the sum, but when

Solution 1:

The problem stems from the fact that i is a sequence, not a single value. In your case, it's np.arange(1,70,1).

This doesn't make sense when you call range(1,i,1): i is not a single value. You can fix it by replacing for l in range(1,i,1) with for l in i.

There are some other problems, too—I'm not sure where cosgamma is defined. You should in the future provide a Minimum, Complete, and Verifiable example.

Post a Comment for "Python Error Only Length-1 Arrays Can Be Converted To Python Scalars"