class Solution(object): def levelOrder(self, root): if root is None: return  q = [[root]] for level in q: record =  for node in level: if node.left: record.append(node.left) if node.right: record.append(node.right) if record: q.append(record) return [[x.val for x in level] for level in q]
Are you a chinese?
python code is much cleaner than other language.
but i have a question about your answer:why it is ok if you change the "q" under the statment"for level in q" but your traversal of q is still make the right output?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.