Hapus semua 0 dari daftar Python
X = [i for i in X if i != 0]
Paiva27
X = [i for i in X if i != 0]
>>> x = [1,2,3,2,2,2,3,4]
>>> list(filter(lambda a: a != 2, x))
[1, 3, 3, 4]