api_limit_status() Remaining hits Key Error Tweepy?Somebody Please Help! This is urgent


I am trying to perform k core analysis on Twitter user. i found this code that fetches friends of user.

import tweepy
import networkx 
from networkx import core
import time
import sys
import json
import codecs
import os

# You must set these with your credentials

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

# For a given user, get their friends, and create a new directed graph
# with the corresponding edges Store the screen names in the edges.
# Note that the API call get_user limits to only the first 100
# friends; more steps need to be taken to expand out to full friend
# lists, but some people's friends lists are really huge.
# If you have a very large number of friends you may need to truncate this list
# to avoid API problems.

AN_HOUR = 3630
TWENTY_MIN = 20*60
THIRTY_MIN = 30*60
LIMIT = 500

def create_egonet(twitter_api, seed_user):
    	print api.me().name
        egonet = networkx.DiGraph()
        if (api.rate_limit_status()['remaining_hits'] < 5):  
        friends = tweepy.Cursor(api.friends, id=seed_user).items(LIMIT)
        print "processing user" + str(seed_user)
        count = 0
        for fr in friends:
            count = count + 1
            egonet.add_edge(seed_user, str(fr.screen_name))
        print str(count) + ' edges added'
        return egonet
    except tweepy.error.TweepError as e:
        print e.reason
        return False


import TweetRecs as tr
import networkx as nx
mainnet=tr.create_egonet(tr.api,‘gilad’) //gilad is twitter user
Tarik Setia //THIS IS My Account Name
Traceback (most recent call last):
File “”, line 1, in
File “TweetRecs.py”, line 60, in create_egonet
if (api.rate_limit_status()[‘remaining_hits’] < 5):
KeyError: ‘remaining_hits’