[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()是对list的函数,所以要用圆括号,而不是方括号

idx = nums.index(target-operand1)

猜你喜欢

转载自www.cnblogs.com/break-dawnn/p/8972882.html