I encountered a similar problem as so many students. Having looked at previous answers, I didn’t find any remedy.

My range in step 2 seems to be fine (isn’t it?) (m-1, -1, -1)

So maybe the problem lies in my pred which is states[z[i -1]]

Please advise, I am stuck!

Thanks,

Doron

Since you are calculating z[i-1] and pred[i-1] then the i-1>=0, right!

Change the range lets see what happens with that!

Sorry I didn’t understand. Should I change the range of *for i in range*? What should I change it to?

If i-1>=0 then i>=1, right! Try changing the range first lets see!

Sure, understood, thanks.