for文の処理:out of rangeのエラーの対処の仕方が分からない
python
morph
[1][2]prefix
morph =[['akuan', 'AKUAN', '1'],
['aku', 'AKUAN', '0'],
['alangkah', 'ALANGKAH', '0'],
['alang', 'ALANGKAH', '0'],
['alang', 'ALangkah', '1'],
['alangkah', 'ALangkah', '0']]
prefix =[]
for k in range(len(morph)):
if morph[k][1] ==morph[k-1][1] and morph[k][2] != morph[k-1][2]:
prefix.append([k-1][k])
>>>prefix
[['akuan', 'AKUAN', '1'],
['aku', 'AKUAN', '0'],
['alang', 'ALangkah', '1']
['alangkah', 'ALangkah', '0']]
IndexError: list index out of range
range(len(morph))
IndexError `k` 1 `prefix.append`
for k in range(1, len(morph)):
prefix.append(morph[k])
`morph[k-1]` append