Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Positional argument follows keyword argument, not sure how to resolve this

How do I fix this error ?

Code:

import pandas as pd 
import seaborn as sns

api_key = 'API_KEY'
channel_id = 'CHANNEL_ID'

youtube = build('youtube','v3', developerKey=api_key)


def get_channel_stats (youtube, channel_id):
    request = youtube.channels().list(
            part= 'snippet','contentDetails','statistics',id=channel_id)
    response = request.execute()
    return response

Error message:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

SyntaxError: positional argument follows keyword argument

How do I avoid this error? I’m making a silly mistake somewhere but not sure how to fix it.

>Solution :

your code look ok you just need to change how you send the part param.

you need a commaseparated string not sevral strings seperated by a comma.

import pandas as pd 
import seaborn as sns

api_key = 'API_KEY'
channel_id = 'CHANNEL_ID'

youtube = build('youtube','v3', developerKey=api_key)


def get_channel_stats (youtube, channel_id):
    request = youtube.channels().list(
            part='snippet,contentDetails,statistics', id=channel_id)
    response = request.execute()
    return response
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading