title: Python: ValueError: 2 is not in list
body: <p>I am beginner to python and I am stuck with this error. It would be of great help if you could tell me where I went wrong. Here is my code:</p>
  
  <pre><code>import math
  import nltk
  import json
  import pymongo
  #import sys
  import nltk.corpus
  
  from funcs import get_name_entity
  from funcs import sentiment_analysis
  from funcs import get_wordlist
  from funcs import get_pos_tag
  
  def get_post(count):
      data = ()
      client = pymongo.MongoClient("localhost", 27017)        #take data from database Mongo
      db = client.News_Updated                                #accessing the database News_Updated
      db.News_Updated.find()
      temp = []
      #print count
      if count == 0:
         data = db.ndtv
      elif count == 1 :
         data = db.timesofindia
      elif count == 2 :
         data = db.hindustantimes
      elif count == 3 :
         data = db.asianetnews
      elif count == 4 :
         data = db.khabarndtv
      #print data.find()
  
      for post in data.find():
          temp.append(post)
      return temp
  
  if __name__ == '__main__':
      count = 0
      limit = -1
      while count &lt; 5:
          data = get_post(count)
          count += 1
          for text in data.index(2):
              print text          
  </code></pre>
  
  <p>However I am getting an output as: </p>
  
  <blockquote>
    <p>Traceback (most recent call last):
      File "main.py", line 43, in 
        for text in data.index(2):
    ValueError: 2 is not in list</p>
  </blockquote>
  
  <p>here is a sample of data from mongodb.</p>
  
  <blockquote>
    <p>{u'url': u'62-year-old-woman-murdered-in-tamil-nadu-s-salem-510469', u'_id': ObjectId('53551ebf39b71c444a991341'), u'data': u"Salem, Tamil Nadu:In a daring daylight murder, a 62-year-old woman was killed by two youths for a gold chain in a busy commercial locality in Salem, Tamil Nadu, police said.Dhanlakshmi was behind the counter of her husband's small shop on Arunachalaachari street in his absence when the assailants slit her throat with a knife and fled away taking the gold chain she was wearing, they said.Arunachalaachari street, dotted with jewellery, vessels and textile shops, is considered a busy commercial locality of the district. The incident sent shock waves among the locals.Deputy Commissioner of Police A G Babu visited the spot."}</p>
  </blockquote>
  
  <p>Any help is greatly appreciated. </p>