On 9/19/07, Boykie Mackay <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I have come across a bit of code to find if a group of numbers is odd or
> even.The code snippet is shown below:
>
> if not n&1:
>     return false
>
> The above should return false for all even numbers,numbers being
> represented by n.I have tried to wrap my head around the 'not n&1' but
> I'm failing to understand what's going on.Could someone please explain
> the statement.


It's just a bitwise and, which will always return 1 for an odd number.

S.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to