Does this work? Is response a string or a dictionary parsed from json? You should be doing something like `response['categories']` instead of doing string parsing - it is far less brittle.