True of False

Steve Holden steve at
Thu Sep 27 19:11:14 CEST 2007

koutoo at wrote:
> I tried writing a true and false If statement and didn't get
> anything?  I read some previous posts, but I must be missing
> something.  I just tried something easy:
> a = ["a", "b", "c", "d", "e", "f"]
> if "c" in a == True:
>      Print "Yes"
> When I run this, it runs, but nothing prints.  What am I doing wrong?
> Thanks.

You are unnecessarily adding a comparison with True. The correct way to 
write that is

if "c" in a:
   print "yes"

Bu of course you haven't actually told us what you really did, because 
the code you represent has syntax errors.

 >>> a = ["a", "b", "c", "d", "e", "f"]
 >>> "c" in a
 >>> if "c" in a == True:
...    print "found it"
 >>> if ("c" in a) == True:
...     print "At last!"
At last!
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd 
Skype: holdenweb

Sorry, the dog ate my .sigline

More information about the Python-list mailing list