python - TypeError: 'int object has no attribute '__getitem__' ... but where? -
for markov chain project writing, generating error @ top of page. know means trying call list method on integer object, must means either a) not initializing list correctly or b) overwriting list integer value @ point in program. however, have been trying debug hours , cannot find issue in small program. error trace follows:
traceback (most recent call last): file "/users/adamlind/pycharmprojects/capstone/song.py", line 9, in <module> musicmarkov.add(["c", 4]) #row file "/users/adamlind/pycharmprojects/capstone/music.py", line 19, in add self._markov.add(inote[0], fnote[0]) file "/users/adamlind/pycharmprojects/capstone/markov.py", line 22, in add self._adjmatrix[val[ival]][val[fval]] += 1 typeerror: 'int' object has no attribute '__getitem__'
and here link github repo containing project (this first stackoverflow question, not sure if frowned upon or not): https://github.com/adamlind323/csc493
i checked through few times couldn't figure out overwriting. i'm not experienced python, , appreciated.
thanks!
val
int. attempt index (val[ival]
) leads exception.
on line #21 intialize val
in following way:
val = self._lookupval[ival]
_lookupval
dictionary defined on line #11 contains integers (see line #14)
Comments
Post a Comment