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:
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