Simple working code to be prompt an unfollow of anyone not following you – using Tweepy

Source code credit given to


I’m modified the code to be simple and all in a single file for those that are not as developer savvy


Tweepy is available here


Once you have the Tweepy API installed and working the following code works flawlessly and is very simple



import tweepy



#Twitter API credentials


screen_name = “”  # Place your username inside “”


consumer_key = “” # your info to be inserted


consumer_secret = “” # your info to be inserted


access_key = “” # your info to be inserted


access_secret = “” # your info to be inserted



auth = tweepy.OAuthHandler(consumer_key, consumer_secret)

auth.set_access_token(access_key, access_secret)

api = tweepy.API(auth)


followers = api.followers_ids(screen_name)

friends = api.friends_ids(screen_name)


for f in friends:

    if f not in followers:

        print “Unfollow {0}?”.format(api.get_user(f).screen_name)

        if raw_input(“Y/N?”) == ‘y’ or ‘Y’:





Leave a Reply

Your email address will not be published. Required fields are marked *