Twitter API.get_user() TypeError: takes 1 positional argument but 2 were given ​

Viewed 5972

I'm still really new to coding and currently taking courses online, in which we are beginning to work with the Twitter API. I am trying to capture the ID of a Twitter account and display it below, but I keep getting this TypeError and can't figure out for the life of me how to fix it. Any help would be appreciated, thanks. My Code

2 Answers

Follow the official documentation on tweepy. Please display code instead of images.

You can use:

api = tweepy.API(auth)
user = api.get_user(screen_name='dak')

print(user.id)

Tweepy v4.0.0 changed API.get_user to not accept any positional arguments.
The 1 positional argument being referred to in the error is self.
You can pass 'dak' as the screen_name keyword argument instead.

Related