"not x in" vs. "x not in"

Sean 'Shaleh' Perry shaleh at valinux.com
Wed Apr 4 12:26:12 EDT 2001


On 04-Apr-2001 Kristian Ovaska wrote:
> list = [1,2,3,4]
> not 5 in list
> 5 not in list
> 
> Why is there a "not in" operator? For clarity?
> 
> (Not that I oppose "not in" in any way. I like it. I'm just curious.)
> 

works in my 1.5.2 interpreter

>>> l = range(0,10)
>>> if 2 not in l:
...   print '2 is not in l'
... 
>>> if 11 not in l:
...   print '11 is not in l'
... 
11 is not in l
>>> 





More information about the Python-list mailing list