Logical AND question

3

3c273

Hello,
Can someone explain to me why only one of these two if/print statements
prints something? Thanks!
Louis

IDLE 1.0.2 print "This doesn't work!"

print "This does!"


This does!
 
T

Tor Iver Wilhelmsen

3c273 said:
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.
 
P

Peter Otten

Tor said:
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
.... print "this works"
....
this works
or the conventional
.... print "but this is more common"
....
but this is more common
Peter
 
3

3c273

Thank you both :)

Peter Otten said:
The original poster probably wants

... print "this works"
...
this works

or the conventional

... print "but this is more common"
...
but this is more common

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,635
Latest member
SkyePurves

Latest Threads

Top