What does "str indices must be integers" mean?

Posted by digitala on Stack Overflow See other posts from Stack Overflow or by digitala
Published on 2010-04-27T10:21:24Z Indexed on 2010/04/27 10:23 UTC
Read the original article Hit count: 257

Filed under:
|

I'm working with dicts in jython which are created from importing/parsing JSON. Working with certain sections I see the following message:

TypeError: str indices must be integers

This occurs when I do something like:

if jsondata['foo']['bar'].lower() = 'baz':
    ...

Where jsondata looks like:

{'foo': {'bar':'baz'} }

What does this mean, and how do I fix it?

© Stack Overflow or respective owner

Related posts about jython

Related posts about python