We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
`def get_siblings(self, node):
assert isinstance(node,TreeNode) if node.parent: siblings = node.parent.children.remove(node) return siblings else: return []`
试运行报错 list.remove(x): x not in list 可是node为什么不在它的parent的children list里面呀
Sorry, something went wrong.
这是大作业,所以我不能直接给你答案,但可以给你一些提示。
lst.remove(x) 这个方法会从列表 lst 中移除找到的第一个 x 元素,注意它直接改变列表对象 lst 的内容,但返回值是 None。所以你的 siblings = node.parent.children.remove(node) 这一句即危险(直接改变了 children 属性的内容使得树结构乱掉)又达不到你想要的效果(siblings 的值将为 None)。
lst.remove(x)
lst
x
None
siblings = node.parent.children.remove(node)
children
siblings
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: