[Tutor] multiple if and or statement

Corey Richardson kb1pkl at aim.com
Mon Mar 14 20:53:15 CET 2011


On 03/14/2011 03:41 PM, 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':

if i == 'test1' or i == 'test2'

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

You are missing something. Before, you're simply testing the existence
of 'test2'. And since 'test2' is an immediate value (so to speak), it
always exists.

-- 
Corey Richardson


More information about the Tutor mailing list