"can't assign to function call" doesn't work for elements of a list

p1 = dType.SetPTPCmd(api,dType.PTPMode.PTPMOVJXYZMode,200,0,85,0,isQueued=1)[0]

The above command works fine.

    for j in range(1, 25):
      p1(j) = dType.SetPTPCmd(api,dType.PTPMode.PTPMOVJXYZMode,200+j,0,0,0,isQueued=1)[0]

But,the above code snippet throws the error “can’t assign to function call”

Please help. Thanks.

Hello, @aiswaryam6874745095, and welcome to the Codecademy Forums!

With the parentheses, p1(j) is regarded as an attempted function call. You may need to use square brackets instead.

Would this work?

    p1 = [None] * 25
    for j in range(1, 25):
      p1[j] = dType.SetPTPCmd(api,dType.PTPMode.PTPMOVJXYZMode,200+j,0,0,0,isQueued=1)[0]

That suggestion is really a guess, since we don’t have the code that precedes what you have posted.

Edited on January 29, 2020 to initialize p1 with None elements.