[Trouble Shooting - Python] TypeError: 'builtin_function_or_method' object is not subscriptable

1. Background: python 3/win10

2. Error Line:

idx = nums.index[target-operand1]

3. Solution

index() is a function on lists, so use parentheses instead of square brackets

idx = nums.index(target-operand1)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325064097&siteId=291194637