[Tutor] The In Operator
Steve Haley
sfhaley at gmail.com
Thu Jul 27 05:19:46 CEST 2006
I am trying to make my way through a book on Python ("Python Ptogramming for
the Absolute Beginner") and have run into some code in the book (and on the
author's accompanying CD) that won't work. I suspect that it might be
because my version of Python is too old (2.1).
The code includes the in operator as follows:
if "Dancing Baloney" in geek:
... print "I know what Dancing Baloney is."
... else:
... print "I have no idea what Dancing Baloney is."
where geek is the nam of a dictionary. "Dancing Baloney is not in the
dictionary so I should get the second print statement as a result but
instead get:
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: 'in' or 'not in' needs sequence right argument
The error message is the same when I run the author's code but the error
statement itself seems to indicate that there IS an in operator. I guess I
really have a three questions. Is the in operator in version 2.1 of
Python? If it is, what is the syntax? (I tried to find it in the help etc.
and couldn't.) Finally, my version of 2.1 came bundled with other software
(ESRI ArcView). Is anyone out there an ESRI user who can tell me if I can I
go ahead and download a newer version without messing up my ArcView
installation?
Thanks,
Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060726/6b0f4076/attachment.htm
More information about the Tutor
mailing list