77 309
Assignments Done
Successfully Done
In July 2019

Answer to Question #8833 in Python for Darcy

Question #8833
what is wrong with this function
def newSequence(ns, n, d):
nValue = 1
for a in ns:
ns[a] -= n*xValue**d
return ns;

compiler error message
line 3, in newSequence
for i in ns:
TypeError: 'int' object is not iterable
Expert's answer
The compiler error message means that in your call of the function 'newSequence'
the first argument 'ns' is an integer
value, though the declaration of that
function requires that 'ns' is a list.

Moreover, it seems that in the
ns[a] -= n*xValue**d
instead of 'xValue' there should

Finally, the loop iteration
for a in ns:
should be
changed to
for a in range(len(ns)):

So the resulting function must
be of the form:

def newSequence(ns, n, d):
nValue =
for a in range(len(ns)):
ns[a] -=
return ns;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions