Python Tweepy – Getting the number of lists a user has been added toReadDiscussCoursesPracticeImprove Article ImproveSave Article SaveLike Article LikeIn this article we will see how we can get the number of lists a user has been added to. The listed_count attribute provides us with an integer denoting the number of public lists a user has been added to. Private lists are not counted.In order to get the number number of public lists a user has been added to, we have to do the following :Identify the user ID or the screen name of the profile.Get the User object of the profile using the get_user() method with the user ID or the screen name.From this object, fetch the listed_count attribute present in it.Example 1: Consider the following profile :We will use the user ID to fetch the user. The user ID of the above mentioned profile is 57741058.# import the moduleimport tweepy # assign the values accordinglyconsumer_key = ""consumer_secret = ""access_token = ""access_token_secret = "" # authorization of consumer key and consumer secretauth = tweepy.OAuthHandler(consumer_key, consumer_secret) # set access to user's access key and access secret auth.set_access_token(access_token, access_token_secret) # calling the api api = tweepy.API(auth) # the ID of the userid = 57741058 # fetching the useruser = api.get_user(id) # fetching the listed_countlisted_count = user.listed_count print("The number of lists the user has been added to are : " + str(listed_count))Output : The number of lists the user has been added to are : 141 Example 2: Consider the following profile :We will use the screen name to fetch the user. The screen name of the above mentioned profile is PracticeGfG.# the screen name of the userscreen_name = "PracticeGfG" # fetching the useruser = api.get_user(screen_name) # fetching the listed_countlisted_count = user.listed_count print("The number of lists the user has been added to are : " + str(listed_count))Output : The number of lists the user has been added to are : 6 Last Updated : 18 Jun, 2020Like Article Save Article Please Login to comment...Similar ReadsPython Tweepy – Getting the number of times a tweet has been retweetedPython Tweepy – Getting the number of times a tweet has been favouritedPython Tweepy – Checking whether a tweet has been liked or notPython Tweepy – Checking whether a tweet has been retweeted or notPython Tweepy – Getting the number of tweets a user has likedPython Tweepy – Getting the number of tweets a user has tweetedPython Tweepy – Getting the number of followers of a userPython Tweepy – Getting the number of friends of a userPython Tweepy - Getting the screen name of a userPython Tweepy - Getting the ID of a userRelated TutorialsPandas AI: The Generative AI Python LibraryOpenAI Python API - Complete GuidePython for Kids - Fun Tutorial to Learn Python ProgrammingData Analysis TutorialFlask Tutorial LikePreviouswxPython - SetAuthNeeded() function in wx.ButtonNext Python Tweepy – Getting the time when a user was createdArticle Contributed By :YYash_RYash_R FollowVote for difficultyEasy Normal Medium Hard ExpertArticle Tags :Python-TweepyPythonPractice Tags :pythonReport Issue