[Tutor] "while" loop for satisfing two conditions ,
Kent Johnson
kent37 at tds.net
Sun Jan 15 14:36:50 CET 2006
> From: John Joseph <jjk_saji at yahoo.com>
> I am trying to use while loop , here I want
> while loop to check for two conditions , I am not
> getting an idea how to use while loop for checking
> two conditions
> I used "&" condition , but it is not
> giving me the expected results
> I used in this way
>
> while (condition no 1) & (condition no2):
> print Results
Use 'and' instead of &. & is a bitwise logical AND - it operates on the individual bits of its arguments. 'and' treats the full operand as a logical value. The results can be different:
>>> [1] & [2]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: unsupported operand type(s) for &: 'list' and 'list'
>>> [1] and [2]
[2]
>>> 2 & 1
0
>>> 2 and 1
1
Kent
More information about the Tutor
mailing list