On 05/03/2017 08:32 PM, Steven D'Aprano wrote:
On Wed, May 03, 2017 at 07:32:53PM -0400, Stephen P. Molnar wrote:
[...]
When it is run I get:
IndexError: list index out of range
That alone is useless to us. Please post the full traceback, starting
from the line
Traceback (most recent call last):
Among other things, it will show us the line of code that causes the
error. Otherwise, we're just guessing.
You might also like to consider a simple debugging technique: print
the index and the length of the list just before trying to use them.
E.g. if you want to extract the nth item of a list, write:
print(n, len(a_list))
value = a_list[n]
(And yes, I completely agree that the error message should show that
information, but it currently doesn't.)
Thanks for the reply.
Here are the error messages:
Enter Molecule ID: A
A.lac.dat
Traceback (most recent call last):
File "<ipython-input-1-47feaf4e6c46>", line 1, in <module>
runfile('/home/comp/Apps/Python/Testing/ReadFile_1.py',
wdir='/home/comp/Apps/Python/Testing')
File
"/home/comp/Apps/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py",
line 866, in runfile
execfile(filename, namespace)
File
"/home/comp/Apps/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py",
line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/comp/Apps/Python/Testing/ReadFile_1.py", line 32, in <module>
atm_chg.append(float( line.split()[-1] ))
IndexError: list index out of range
--
Stephen P. Molnar, Ph.D. Life is a fuzzy set
www.molecular-modeling.net Stochastic and multivariate
(614)312-7528 (c)
Skype: smolnar1
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor