Skip to content Skip to sidebar Skip to footer

Indentationerror With Python

I am currently trying to stream tweets for a project using Python, Elasticsearch and Kibana. While running my Python script, I have an IndentationError and I don't understand why,

Solution 1:

You do have tabs there.

defon_data(self, data):
        dict_data = json.loads(data)
# ^ tab and 4 spaces here
        tweet = TextBlob(dict_data["text"])
# ^ 8 spaces here           print(tweet.sentiment.polarity)
# ^ ^ two tabs here (equal 16 spaces)

Note that the representation in SO site translates the tabs to spaces, but if you copy the source into a code editor, it reveals the tabs:

indentation

Post a Comment for "Indentationerror With Python"