- [Instructor] In this self check exercise
I'd like you to use a cursor object
as I demonstrated in the preceding video
this time to get and display ten followers
for the NASAKepler account that you used
in the preceding self check exercise.
So go ahead and pause the video and give that a shot
then come back here to see the answer.
Okay first step is going to be to create the list
in which you're going to store the actual user names
that come back.
Then we of course need to set up the Tweepi cursor.
Again we'll be calling the API objects followers method
this time however we're going to pass to that method
the NASAKepler account as the argument.
So once you have that cursor remember that it is lazy
and it doesn't do anything until you iterate over it
and the way you start to do that
is by calling the cursor's items method.
The cursor's items method
is going to receive as it's argument
the number of total items you would like to get
and again it will manage not only invoking the Twitter API
over the internet for you
but it will work in if you've configured the API object
to wait on rate limits doing the automatic waiting for you.
So depending on how many accounts you're actually requesting
to get followers for the Kepler account here,
this loop could take a very long time to execute
if you hit those rate limits for a 15 minute interval.
So for each of the accounts that we get
we're going to grab that screen name
and append it to the list.
So I'll go ahead and execute that.
And by the way when you execute those API calls,
those API object calls,
remember there could be delays
because those are making requests over the internet
so things like your connection speed
could affect how fast results come back to you.
And then finally we're going to join together
by spaces the followers.
In this case we didn't bother to sort them alphabetically
we simply concatenated them for display purposes.