-2
我很疑惑为什么下面的代码没有正确地弹出并扩展它标识的每个零的列表。检测并将零移到列表的末尾
def move_zeros(array):
array.extend([array.pop(i) for i,x in enumerate(array) if x != 0 and x != False])
return array
类似的帖子,我的答案回顾: How to move zeros to the end of a list [closed]
不要更改要迭代的数组。 – spectras