Reputation: 97
I want to create a friends_list for each user ID in the usr list. This is what I have tried so far. I don't know how to call friends_list for each one or even all of them together in one list.
def first_surface(friends):
usr = ['298970145', '11922952', '17455195']
for i in usr:
friends_list = []
for user in tweepy.Cursor(api.friends, user_id = usr).items(15):
friends_list.append(user.id)
return
Upvotes: 0
Views: 61
Reputation: 97
I have got what I wanted with the code below:
friends_list = []
usr_all = ['298970145', '11922952', '17455195'];
for usr in usr_all:
for user in tweepy.Cursor(api.friends, user_id = usr).items(15):
friends_list.append(user.id)
However, I still don't know how to retrieve the friend_list for user 1 in the list for example.
Upvotes: 1
Reputation: 142
Does this work? it creates a list of the friends lists
def first_surface(friends):
usr = ['298970145', '11922952', '17455195']
list_of_friends = []
for i in usr:
friends_list = []
for user in tweepy.Cursor(api.friends, user_id = usr).items(15):
friends_list.append(user.id)
list_of_friends.append(friends_list)
return list_of_friends
If you want to know the friends list for the first user, it would simply be list_of_friends[0]
Upvotes: 1