Logical AND question
Peter Otten
__peter__ at web.de
Thu May 13 12:42:43 EDT 2004
Tor Iver Wilhelmsen wrote:
> "3c273" <nospam at nospam.com> writes:
>
>> >>> if s and t == '':
>> print "This doesn't work!"
>
> This is really
>
> if (s) and (t == '')
>
> which evaluates to false since "if (s)" returns false for the empty
> string.
The original poster probably wants
>>> if s == t == "":
... print "this works"
...
this works
>>>
or the conventional
>>> if s == "" and t == "":
... print "but this is more common"
...
but this is more common
>>>
Peter
More information about the Python-list
mailing list