0

I have a list of users, and I want to get the followees of each user in the list. I want to save the followees in a different variable for each user.

USER = "x"

profile = instaloader.Profile.from_username(L.context, USER)

x = list(profile.get_followees())

So, the loop should pick an element for the list (let's name it x), assigning it to USER, execute the following code, and assign the resulting list to a variable with its name. Also, because how instaloader works, each element on the list should be converted to string before being assigned to USER.

Does that make sense?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • 2
    Any time you think you need dynamic variable names like this, you should be using a dictionary. – Barmar Oct 05 '20 at 16:26
  • 1
    What @Barmar said. It's technically possible to dynamically generate variable names but usually when someone asks how to do this it's because they haven't yet learned how collections (e.g. lists and dicts) work. Could you give more background on what you're going to do with all these variables/values after you've generated them? – Samwise Oct 05 '20 at 16:29
  • The starting point is a user list. After the loop, I want to know the followees of each user in the list. If I store them all in the sale variable, I won't know which followee is from which user. – Alberto Asenjo Oct 05 '20 at 17:40

0 Answers0