'for' loop in python, error: unsubscriptable object

george georgeyu1981 at hotmail.com
Mon Nov 18 04:55:17 EST 2002


Hello:
   I am new to python.
   I wrote a for loop:
The program like this:
 >  def heat(CLA, RBW, BAG, MRB, NOG):
   
   import string
   name = []
   str1 = " the Clangers"
   str2 = "Rainbow"
   str3 = "Bagpuss"
   str4 = "Mr Benn"
   str5 = "Noggin the Nog"
  

   
   
   for max in range[CLA, RBW, BAG, MRB, NOG]:
     if max == CLA:
       name.append(str1)
     elif max == RBW:
       name.append(str2)
     elif max == BAG:
       name.append(str3)
     elif max == MRB:
       name.append(str4)
     elif max == NOG:
       name.append(str5)
   return name
BUT WHEN I EXECUTE IT ,
THE PROGRAM SAYS "for max in range[CLA, RBW, BAG, MRB, NOG]:
                  type error: unsubcriptable object"

could you help me,please!!!!!



More information about the Python-list mailing list