A list contains several NoneType
elements. To skip the NoneType
,
for item in list :
if item is not None :
fp.write(item + '\n')
#OR
for item in list :
try :
fp.write(item + '\n')
except :
pass
Which one is better and why?