Writing to files
dworkin at ccs.neu.edu
Mon Mar 20 23:09:52 CET 2000
"Daley, MarkX" <markx.daley at intel.com> writes:
> Here is a piece of code I wrote to write the items in a list sequentially to
> a file.
> a=some list ([1,2,3,whatever])
> for x in a:
> When I run it, I get this:
> Traceback (innermost last):
> File "<pyshell#2>", line 1, in ?
> File "C:\PROGRA~1\Python\collect.py", line 30, in collect
> TypeError: sequence index must be integer
> Any ideas on what is causing this?
x is not an integer.
Perhaps instead of f.write(a[x]), you just wanted f.write(x)?
More information about the Python-list