Есть идеи, почему python3 не рассматривает False как bool? Я хочу переместить все нули в конец списка.
def move_zeros(array):
for i in array:
if type(i) is not bool:
if i == 0:
array.append(int(i)) # catching non bool values that are zeros, adding at the end of the list
array.remove(i) # removing original
elif type(i) is bool:
pass #Here it catches False from the input, it should do nothing but somehow it is moved to the end of the list as zero in the output.
return array
print(move_zeros(["a", 0, 0, "b", None, "c", "d", 0, 1,
False, 0, 1, 0, 3, [], 0, 1, 9, 0, 0, {}, 0, 0, 9]))
Вывод:
['a', 'b', None, 'c', 'd', 1, 1, 3, [], 1, 9, {}, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]