Created
June 30, 2010 07:19
-
-
Save shihongzhi/458354 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def odd(n): | |
return n%2 | |
li=[1,2,3,5,9,10,256,-3] | |
filter(odd,li) //输出[1,3,5,9,-3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another way is just checking to see if the LSB is set:
That is a much quicker operation than modulus, but not sure if it's faster in a language like python. Cheers!