Problem with Lists & Index command

Benjamin Schollnick rfreedm1 at nospam.rochester.rr.com
Fri Jun 11 17:12:00 EDT 1999


Hi All!

I've doing some python programming, and while I'm still learning
I'm getting better every day >g<

But this has me puzzled....

I'm trying to use a list that contains multiple pieces of 
information...
Basically a list that contains the equivalent of a "Array"....

And I'm not getting a error, but INDEX doesn't seem to want
to work.... Here's a "test program" made out of a clip from the
program....

import string

entry   = 'ABCD'

tcmlist = [('EFGHI',1),('JKLMN',2),('ABCD',3)]
found   = 0
entry   = string.upper(string.strip(entry))

try:
        found = tcmlist.index (entry)
        tcmlist[found][1] = tcmlist[found][1] + 1
        print 'found'
except ValueError:
        tcmlist.append (entry,1)
        print 'Sorry could not find it'
else:
        pass

print tcmlist

I don't see anything that looks wrong, and getting 
no syntax errors, but....

It appears that INDEX doesn't work on a multiple
dimension list????

I've worked around it for now, but it would be sooooo
much neater (for my program code, etc) if it worked..

Suggestions?

			- Benjamin




More information about the Python-list mailing list