Getting "TypeError:list indices must be integers"

Girish Sahani girish at cse.iitb.ac.in
Tue Jun 13 02:11:48 EDT 2006


Hi,
Please check out the following loop,here indexList1 and indexList2 are a
list of numbers.

for index1 in indexList1:
  for index2 in indexList2:
    if ti1[index1] == ti2[index2] and not index1 != indexList1.pop():
       index1+=1
       index2+=1
       continue
    elif index1 == indexList1.pop() and charList in pairList:
       k = string2.index(char2[0])
       instance = ti2(k)
       tiNew = ti1.append(instance)
       tiNewList.append(tiNew)
    else:
       break

On running my program, python gives me a TypeError saying:

   if ti1[index1] == ti2[index2] and not index1 != indexList1.pop():
TypeError: list indices must be integers

Even though index1 and index2 are really integers.Please help!






More information about the Python-list mailing list