If the following program change list[2] to 2010, replacing 1997 (and it does), why doesn't the second program work in changing line[ 9:11] to 20 from 08?
FIRST PROGRAM:

   list = ['physics', 'chemistry', 1997, 2000]
   print list[2]
   list[2] = 2010
   print list[2]

OUTPUT:

   1997
   2010

SECOND PROGRAM:
   line = [2010020820841134]
   if line[ 9:11] == "08":
       line[ 9:11] = 20
       print line[ 9:11]

OUTPUT:

   "TypeError: 'str' object does not support item assignment."


Thanking you all in advance,

Ken
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to