Hi, Ny friends,

This is my 2nd week to learn and wite codes in python. I encounter a debug error in the last line of code or SizeDiffE(k) = j
. I could not figure out? I am using SPE IDE 0.8.3 to debug.

for k in range(1, NoE):
for j in range(1, Nobs):
if j == 1:
if Price(j, k) > 0:
SizeDiffB(k) = j
elif j > 1 and j < Nobs:
if Price(j - 1, k) == 0 and Price(j, k) > 0:
# we find the begining of data point for equity k
SizeDiffB(k) = j
elif Price(j - 1, k) > 0 and Price(j, k) ==0:
# we find the end of data point for equity k
SizeDiffE(k) = j - 1
elif j == Nobs:
if Price(j, k) > 0:
SizeDiffE(k) = j


Thanks so much. please help.

John

Recommended Answers

All 3 Replies

The code is working perfectly well...
You must have made an indentation mistake

The code is working perfectly well...
You must have made an indentation mistake

I use SPE IDE 0.8.3. I tried several times on indentation. It looks like there is no indentation mistake. But when I run the script. It always points to last line with the syntax error: can't assign to function call. But you can see there is no function in last line of code at all:
SizeDiffE(k) = j

Any idea? and many thanks.

John

But you can see there is no function in last line of code at all:
SizeDiffE(k) = j

Try a
print type(SizeDiffE)
to see what it is. Also, if SizeDiffE(k) is not passing 'k' to the function SizeDiffE() then what is it doing. If it is a tuple, then it can't be modified. If it is a list then use
SizeDiffE[k] = j
It is difficult to tell with just this snippet of the program, so post some code on what these variables do as well. Also, comment the last line to confirm that it is the error. It may be printing the error after the last line, but referring to a previous line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.