I saw someone post the following answer to tell the difference between if pass and if continue. I know that the list is "a" [0,1,2], I just donβt know what the result is for "if not element"? Why when using continue, 0 is not printed, only 1 and 2 are printed? when a = 0, "if not an element" is "if not 0", does it have special meaning?
>>> a = [0, 1, 2] >>> for element in a: ... if not element: ... pass ... print element ... 0 1 2 >>> for element in a: ... if not element: ... continue ... print element ... 1 2
source share