thanks much you really helped me if anyone wants here is the program: n2=2 n3=3 n4=4 n5=5 n6=6 n7=7 l2=[] l3=[] l4=[] l5=[] l6=[] l7=[] while n2 < 1000: l2.append(n2) n2=n2+2 while n3 < 1000: l3.append(n3) n3=n3+3 while n4 < 1000: l4.append(n4) n4=n4+4 while n5 < 1000: l5.append(n5) n5=n5+5 while n6 < 1000: l6.append(n6) n6=n6+6 while n7<1000: l7.append(n7) n7=n7+7 possible=[] for num in l2: if num in l3 and num in l4 and num in l5 and num in l6: possible.append(num) for a in possible: if a+1 in l7: print a+1
On Aug 24, 2007, at 1:25 AM, Alan Gauld wrote: > > "max baseman" <[EMAIL PROTECTED]> wrote >> im checking if a number is in all 5 of the other lists and when >> i use the and command it seems to just be checking if it's in a >> least >> one of the others, > > >> for num in l2 and l3 and l4 and l5 and l6: # here seems to be the > > Try: > > if num in I2 and num in I3 and num in I4 and num in I5 and num in I6: > > In your case you are 'and'ing the lists which is a boolean expression > and because of how Python does short circuit evaluation it returns > the last list > >>>> a = [1,2] >>>> b = [3,4] >>>> a and b > [3, 4] > > so > > for n in a and b: > > is the same as > > for n in b: > > which iterates over b... > > HTH, > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.freenetpages.co.uk/hp/alan.gauld > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor