IndentationError running python script
<p>Im very new to python and Im trying to run this script but keep getting indentation errors in this part:</p>

<pre><code>while (time.time()-self.time) &amp;lt; self.limit
</code></pre>

<p>I have tried to remove all indentation and then ree-indent in different ways but nothing seems to work. Does anyone have an idea? Im using Spyder to run this.</p>

<pre><code>start_time = time.time() #grabs the system time
keyword_list = ['twitter'] #track list

from pymongo import MongoClient
import json

class listener(StreamListener):

    def __init__(self, start_time, time_limit=60):

        self.time = start_time
        self.limit = time_limit

def on_data(self, data):

while (time.time()-self.time) &amp;lt; self.limit:
    try:

    client = MongoClient('localhost', 27017)
    db = client['twitter_db']
    collection = db['twitter_collection']
    tweet = json.loads(data)
    collection.insert(tweet)

    return True


    except BaseException, e:
    print 'failed ondata,', str(e)
    time.sleep(5)
    pass

exit()

def on_error(self, status):
print statuses
</code></pre>

<p>The methods of your class must be indented under your <code>class</code> statement and the body of the methods must be indented under the <code>def</code> line. The body of the <code>try</code> and <code>except</code> blocks must be indented under those statements.</p>

<pre><code>start_time = time.time() #grabs the system time
keyword_list = ['twitter'] #track list

from pymongo import MongoClient
import json

class listener(StreamListener):

    def __init__(self, start_time, time_limit=60):

        self.time = start_time
        self.limit = time_limit

    def on_data(self, data):

        while (time.time()-self.time) &lt; self.limit:
            try:
                client = MongoClient('localhost', 27017)
                db = client['twitter_db']
                collection = db['twitter_collection']
                tweet = json.loads(data)
                collection.insert(tweet)
                return True

            except BaseException, e:
                print 'failed ondata,', str(e)
                time.sleep(5)
                exit()

    def on_error(self, status):
        print statuses
</code></pre>

python