List of non-zero elements in a list in Python,b = [int(i != 0) for i in a]