Re: [Tutor] Checking in lists

2006-04-26 Thread Alan Gauld
> Basically it's not evaluating it the way you think it is: > >Your first example really equates to: > > if (1 or 5) in rollList: Not quite, its doing: if 1 or 5 in rollList: We can demonstrate that with: >>> if 1 or 0 in [6,2,3]: print 'True' ... True >>> if (1or 0) in [6,2,3]: print 'True' ..

Re: [Tutor] Checking in lists

2006-04-26 Thread Kent Johnson
Jason Massey wrote: > John, > > Basically it's not evaluating it the way you think it is: Right. > > Your first example really equates to: > > if (1 or 5) in rollList: >etc... > > (1 or 5) equals 1 and 1 isn't in the your list. Not quite. It's if 1 or (5 in rollList): Since 1 evaluat

Re: [Tutor] Checking in lists

2006-04-26 Thread Jason Massey
John,Basically it's not evaluating it the way you think it is:Your first example really equates to:if (1 or 5) in rollList:   etc...(1 or 5) equals 1  and 1 isn't in the your list. On 4/26/06, John Connors <[EMAIL PROTECTED]> wrote: G'day,I found something today that has me confused. I'm making a l

[Tutor] Checking in lists

2006-04-26 Thread John Connors
G'day, I found something today that has me confused. I'm making a list of 6 random dice rolls and I want to check if any 1's or 5's were rolled. I tried this way first and it returns true even if there are no 1's or 5's. I'll use a roll of all 2's as an example. rollList = [2,2,2,2,2,2] if 1