dictionaries and 'in' in 2.1

John J. Lee jjl at pobox.com
Sat Nov 3 21:46:08 CET 2001

The Python 2.1.1 manual, section 2.1.6, says:

  k in a        1 if a has a key k, else 0
k not in a      0 if a has a key k, else 1

But when I attempt to use this feature, I get:

Python 2.1.1 (#1, Oct 23 2001, 15:59:13)
[GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> d = {1:2}
>>> 1 in d
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: 'in' or 'not in' needs sequence right argument

I must be doing something stupid, but I don't see what.

Thanks for any help.


More information about the Python-list mailing list