Python, I want to make list json.dumped But, error 'dict' object has no attribute 'dumps'
Question: below is my python code

    
    
    r = requests.get("https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&channelId="+CHANNELID+"&order=date&key="+DEVELOPER_KEY)         
    json = r.json()                                                                                                                                           
    items = json.get("items")                                                                                                                                 
    videos = []                                                                                                                                               
    for x in items:                                                                                                                                           
      title = x["snippet"]["title"]                                                                                                                           
      videoId = x["id"]["videoId"]                                                                                                                            
      channelTitle = x["snippet"]["channelTitle"]                                                                                                             
      cam_thumbnails = x["snippet"]["thumbnails"]["medium"]["url"]                                                                                            
      publishedAt = x["snippet"]["publishedAt"]                                                                                                               
      data = { "title" : title,                                                                                                                               
               "videoId" : videoId,                                                                                                                           
               "channelTitle" : channelTitle,                                                                                                                 
               "cam_thumbnails" : cam_thumbnails,                                                                                                             
               "publishedAt" : publishedAt,                                                                                                                   
               }                                                                                                                                              
      videos.append(data)                                                                                                                                     
    print json.dumps(videos) # this code cause problem
    

I inserted 'dict' to 'list' and then called json.dumps() But, error was arised
error messege is 'dict' object has no attribute 'dumps'

What is problem?, and How can I solve this problem?


Answer: Previously, you must have imported the json module, writing `import json`,
which creates a variable in your namespace, whose name is `json`. Then, you do
`json = r.json()`, ie. you assign a new reference to the name `json`, which
doesn't represents the _module_ json anymore, but, instead, the result of the
`r.json()` method. Thus, you can't use anymore the json module using the
syntax `json.function()`, because json is the result of r.json(). To resolve
your problem, you must change the name of the variable named `json` in your
example, to, for example, `json_dict` or anything else.

