The second will not be good, because it throws an exception whenever an element of type occurs None. The exception will be handled differently in python.
In your case, you give a pass, so that will be done.
Cleaner way:
clean = [x for x in lis if x != None]
or As stated in the comments, which you can also use, no, even if it is essentially compiled into the same bytecode:
clean = [x for x in lis if x is not None]
Hope this helps. When in Rome they do as the Romans :)
source
share