list looping error

tkpmep at hotmail.com tkpmep at hotmail.com
Fri Dec 29 07:52:30 EST 2006


What you really want to write is
for i in x:
    for j in i:
        print j

The outer loop iterates over the tuples in the list, while the inner
loop iterates over the elements of each tuple. So j (in your example)
is always an integer, and is therefore unsubscriptable, which is
exactly what the error message says.

Thomas Philips




More information about the Python-list mailing list