[Tutor] newbie question about list element manipulation after split()
coyote_v2002 at yahoo.com
Thu Oct 16 10:25:01 CEST 2008
I feel very stupid, but I am stuck. I could try some workaround, but I want to understand what I am doing wrong.
for line in open("parameterfile").readlines( ):
print line.split() # trouble line
The "trouble line" works fine in this example. It prints
what I want, something which looks like lists of words:
['CT', 'CT', '268.0', '1.529']... etc.
However, if I want to manipulate the individual list elements, I run into trouble. While
still works, (it yields CT - first element),
File "readatoms.py", line 103, in <module>
IndexError: list index out of range
Could you please tell me what's wrong. (I come from Perl background so Python seems out-of-the-body experience to me).
More information about the Tutor