Sets are also available as a moddule in python 2.3. This code would work if you first import:

from sets import Set as set



Douglas S. Blank wrote:
Logan,

I believe you need Python 2.4 which added the "set" function.

-Doug

Przemyslaw Kisicki wrote:

I use:
--------------------------------------------------------------------------------


Python 2.3.4 (#2, Aug 19 2004, 15:49:40) [GCC 3.4.1 (Mandrakelinux (Alpha
3.4.1-3mdk)] on linux2 ... IDLE 1.0.3
--------------------------------------------------------------------------------


I was trying to write:
--------------------------------------------------------------------------------



basket=['apple','orange','apple','pear','orange','banana']
fruits=set(basket)


--------------------------------------------------------------------------------

and I get:
--------------------------------------------------------------------------------


Traceback (most recent call last): File "<pyshell#322>", line 1, in
-toplevel- fruits=set(basket) NameError: name 'set' is not defined

--------------------------------------------------------------------------------

What's wrong? How to use sets?

Logan
_______________________________________________
IDLE-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/idle-dev




_______________________________________________
IDLE-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/idle-dev

Reply via email to