Hi Python Tutors:
I have a data structure that looks like:
>>> test=[[1,2,3],[4,5,6],[7,8,9]]
I want to define a new variable that captures the second element of each
sublist from above:
>>> testvar2 = []
Next I try to capture the aforementioned elements:
>>> for i in len(test):
testvar2.append(test[i][2])
I want testvar2 = [2,5,8] but instead I get the following error message:
Traceback (most recent call last):
File "<pyshell#34>", line 1, in <module>
for i in len(test):
TypeError: 'int' object is not iterable
Any insight would be appreciated.
Thanks
Steve
--
Steven Buck
Ph.D. Student
Department of Agricultural and Resource Economics
University of California, Berkeley
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor