Typeerror

jonbutler88 at googlemail.com jonbutler88 at googlemail.com
Wed May 21 05:02:22 EDT 2008


On May 21, 9:58 am, Freaky Chris <angry-ch... at hotmail.com> wrote:
> This is a simple error, you are passing the variable res as an interger to
> use for a slice when what ever you are storing in res isn't an integer.
>
> Chris
>
>
>
> Beema shafreen wrote:
>
> > Hi all,
> > I getting the following error when i run my scirpt ,
> > can somebody help me regarding this to solve the type error problem
>
> > Traceback (most recent call last):
> >   File "get_one_prt_pep.py", line 59, in ?
> >     if len(data[res])<=1:
> > TypeError: string indices must be integers
>
> > --
> > Beema Shafreen
>
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> --
> View this message in context:http://www.nabble.com/Typeerror-tp17358659p17358932.html
> Sent from the Python - python-list mailing list archive at Nabble.com.

If it is an integer, but stored as a string you can use:

if len(data[int(res)])<=1

its not pretty but it should sort out the type errors



More information about the Python-list mailing list