** Operator Typeerror
Solution 1:
I think you have a mistake on this line:
result = (x, power, epsilon)
I suspect you want to be calling the findroot
function with those three values as arguments rather than creating a tuple out of them. Try changing it to:
result = findroot(x, power, epsilon)
Solution 2:
result**power
is trying to find x to the y
where x = result
and y = power
.
Your problem is that result
is a tuple. You can't raise a tuple to a power. It makes no sense...
You need to access the value inside the tuple that is supposed to be exponentiated and exponentiate that.
For instance, result[0] ** power
, result[1] ** power
, etc.
Solution 3:
It looks like you meant to call findRoot
with the three arguments x
, power
, and epsilon
. Try editing the line
result = (x, power, epsilon)
to be
result = findRoot(x, power, epsilon)
As that line presently is, result
is not a number (which you'd want for the **
operator). result
a tuple that has three different objects in it: x
, power
, and epsilon
. You can use the **
operator on any two of the items in result
but it's not defined for the tuple
type.
Solution 4:
You can't apply a powers operation to a tuple. If you need to have all of the values to that power, try operating them separately.
You might need: [power**n for n in result]
Post a Comment for "** Operator Typeerror"