Using while loop and if statement to tell if a binary has an odd or even number of 1's.

todpose at hotmail.com todpose at hotmail.com
Wed Feb 4 20:02:48 EST 2009


Using while loop and if statement, I'm trying to get Python to tell me whether there are even or odd number of 1's in a binary representation.
For example, if I give Python a 00000111, then I want it to say that the binary representation given has an odd number of 1's.
If I give it 00010111, then it will tell me that there is an even number of 1's.
I'd appreciate any suggestion.
Thanks!
_________________________________________________________________
So many new options, so little time. Windows Live Messenger.
http://www.microsoft.com/windows/windowslive/messenger.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090204/fe6dac1a/attachment.html>


More information about the Python-list mailing list