TypeError: list indices must be integers

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Wed Dec 31 03:11:12 CET 2008


On Tue, 30 Dec 2008 17:46:11 -0800, dubux wrote:

> i keep getting "TypeError: list indices must be integers" on the
> following line "date = mylist[y]"
> can someone please explain this and give me the proper way to achieve
> what im trying to do?

The obvious question is, what is the value of y?

Insert a line:

print type(y), y


immediately before date = mylist[y] and see what it says. I'm guessing 
that it will say that y is a string.


-- 
Steven



More information about the Python-list mailing list