On 14/03/11 19:41, Mike Franon wrote:
HI,

I had a question, when running this small snippet of test code:



a = ['test1', 'flag', 'monday']

for i in a:
     if i == 'test1' or 'test2':
        print 'true'


It always prints true


$ ./testing.py
true
true
true


I know I am missing something, but in reality it should only print
true once correct?

Any string that isn't blank ie '' is true. In your test you've asked whether i == 'test1' is true or 'test2' is true not i == 'test2' is true. I hope that's not too confusing, I can make it clearer if you're having a problem.

Adam.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to