Python error "TypeError: unsupported operand type(s) for -: 'list' and 'int'"

697    Asked by Ethan Clark in Python , Asked on Mar 2, 2021
Answered by Ethan Clark

The issue with your code is that on the last second line you are trying to subtract 1 from a list, which is why you are getting this error. I think what you are trying to do is this:

chain.append(np.random.choice(word_dict[chain[-1]]))



Your Answer

Interviews

Parent Categories