'Tweepy Error Python With Username Finding Top Tweet

I'm making a program in Python, using Tweepy, that gets the top Tweet from a user, but for some reason it gives me am error when I try to run the program. Here is my code and my error I got.

import tweepy
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
username='@username'
tweets_list= api.user_timeline(username, count=1)
tweet= tweets_list[0] 
print(tweet.created_at)
print(tweet.text)
print(tweet.in_reply_to_screen_name) 

Here is my error:

Traceback (most recent call last):
  File "main.py", line 10, in <module>
    tweets_list= api.user_timeline(username, count=1) # Get the last tweet
  File "/home/runner/elon-tweet/venv/lib/python3.8/site-packages/tweepy/api.py", line 33, in wrapper
    return method(*args, **kwargs)
  File "/home/runner/elon-tweet/venv/lib/python3.8/site-packages/tweepy/api.py", line 46, in wrapper
    return method(*args, **kwargs)
TypeError: user_timeline() takes 1 positional argument but 2 were given


Solution 1:[1]

API.user_timeline was changed in Tweepy v4.0.0 to no longer accept positional arguments.
The 1 positional argument being referred to in the error is self.
You probably want to pass username as the screen_name keyword argument instead.
See also the relevant FAQ section in Tweepy's documentation about this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Harmon758