7.15. Removing Falses from List#
names=['Sahil',1,0,False,None,""," "]
[i for i in names if i]
['Sahil', 1, ' ']
The last section if i removes all the false and in python : 0,False,empty strings are considered false
[i for i in names if i and i!=" "]
['Sahil', 1]
adding one more condition will remove those spaces also