我正进入(状态
TypeError: 'NoneType' object is not iterable
当我尝试查找列表的总和时。
出现问题的地方:
if(sum(self._candidates) + self._allCandidates[self._depth]._weight > 20):
self._left = Node(self._candidates, self._depth + 1, self._allCandidates)
else:
self._left = Node(self._candidates.append(self._allCandidates[self._depth]), self._depth + 1, self._allCandidates)
节点定义:
def __init__(self, candidates = [], depth = -1, allCandidates = []):
self._candidates = candidates
self._depth = depth
self._allCandidates = allCandidates
感谢您对此事的任何帮助。