tweepy IndexError: list index out of range
<p>This could be a super stupid mistake, but I just cant see what's wrong.</p>

<pre><code>class listener(tweepy.streaming.StreamListener):
    def on_data(self, data):
        tweet = data.split(',"text":"')[1].split('","source')[0]
        screen_name = data.split(',"screen_name":"')[1].split('","location":')[0]
        print tweet
        print data
        return True
    def on_error(self, status):
        print status

def main():
    twitterStream = tweepy.Stream(auth, listener()) 
    twitterStream.userstream()

if __name__ == "__main__":
    main()
</code></pre>

<p>and the error is:</p>

<pre><code>Traceback (most recent call last):
  File "C:\Rex\702_EH\new 1.py", line 35, in &lt;module&gt;
    main()
  File "C:\Rex\702_EH\new 1.py", line 32, in main
    twitterStream.userstream()
  File "build\bdist.win32\egg\tweepy\streaming.py", line 394, in userstream
  File "build\bdist.win32\egg\tweepy\streaming.py", line 361, in _start
  File "build\bdist.win32\egg\tweepy\streaming.py", line 294, in _run
IndexError: list index out of range
</code></pre>

<p>can anyone help me with this please?</p>

<p>The output of Tweepy response is JSON. Because JSON is an standard in intra-communicating between applications you should follow this standard by using json lib in python. So you need to load Tweepy response like this:</p>

<pre><code>tweet = json.loads(data)
username = tweet[user][screeen_name]
language = tweet[user][lang]
......
.....
</code></pre>

python split tweepy