[Tutor] IndexError: list index out of range [ Program work fine , but gives this message , guidance requested ]

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Jan 9 20:08:38 CET 2006


> lot for the advice I got my concepts of def of functions , sort
> functions , count , cleared for me
>                I was able to do and understand all the
>  function example , except “item_comparison” function
>            I get the error  for set
>  >>> set((1,1,1,2,2,2,2,2,3,4,4,5))
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> NameError: name 'set' is not defined

Hi John,

For Python 2.3.4, you'll need to add the line:

######
from sets import Set as set
######

before trying to use 'set'.  Sets weren't so built into Python until
Python 2.4, and so examples that use 'set()' will need that above line to
install the proper support.

Best of wishes!



More information about the Tutor mailing list