title: How do I iterate through a nested list from Spotipy's playlist_items function and only print out the fields I'm interested in?
body: <p>I am attempting to get all the track names and corresponding artist from a playlist using Spotipy. I am at the point where I am able to get a json dump of the fields, but I cannot figure out how to iterate through the dump and print out the fields I'm interested in.</p>
  <p>Here is what I'm using to get all information about the playlist:</p>
  <p><code>playlist = spotipy.playlist_items(playlist_id)</code></p>
  <p>If I then <code>print(json.dumps(playlist, indent=2))</code>, then I get the following output:</p>
  <pre><code>{
    &quot;collaborative&quot;: false,
    &quot;description&quot;: &quot;&quot;,
    &quot;external_urls&quot;: {
      &quot;spotify&quot;: &quot;https://open.spotify.com/playlist/50uWPcNFdJElMVZWo0IebB&quot;
    },
    &quot;followers&quot;: {
      &quot;href&quot;: null,
      &quot;total&quot;: 0
    },
    &quot;href&quot;: &quot;https://api.spotify.com/v1/playlists/50uWPcNFdJElMVZWo0IebB?additional_types=track&quot;,
    &quot;id&quot;: &quot;50uWPcNFdJElMVZWo0IebB&quot;,
    &quot;images&quot;: [
      {
        &quot;height&quot;: 640,
        &quot;url&quot;: &quot;https://i.scdn.co/image/ab67616d0000b273942a0c9ac8f1def7c8805044&quot;,
        &quot;width&quot;: 640
      }
    ],
    &quot;name&quot;: &quot;Spotipy Test&quot;,
    &quot;owner&quot;: {
      &quot;display_name&quot;: &quot;username&quot;,
      &quot;external_urls&quot;: {
        &quot;spotify&quot;: &quot;https://open.spotify.com/user/username&quot;
      },
      &quot;href&quot;: &quot;https://api.spotify.com/v1/users/username&quot;,
      &quot;id&quot;: &quot;username&quot;,
      &quot;type&quot;: &quot;user&quot;,
      &quot;uri&quot;: &quot;spotify:user:username&quot;
    },
    &quot;primary_color&quot;: null,
    &quot;public&quot;: false,
    &quot;snapshot_id&quot;: &quot;Nyw0OTk4MDg1NDM3NzRlOWI2MGY2MDc2ZjMxNTE4OGFkZWQ5Y2QyZDdk&quot;,
    &quot;tracks&quot;: {
      &quot;href&quot;: &quot;https://api.spotify.com/v1/playlists/50uWPcNFdJElMVZWo0IebB/tracks?offset=0&amp;limit=100&amp;additional_types=track&quot;,
      &quot;items&quot;: [
        {
          &quot;added_at&quot;: &quot;2021-11-17T07:32:59Z&quot;,
          &quot;added_by&quot;: {
            &quot;external_urls&quot;: {
              &quot;spotify&quot;: &quot;https://open.spotify.com/user/username&quot;
            },
            &quot;href&quot;: &quot;https://api.spotify.com/v1/users/username&quot;,
            &quot;id&quot;: &quot;username&quot;,
            &quot;type&quot;: &quot;user&quot;,
            &quot;uri&quot;: &quot;spotify:user:username&quot;
          },
          &quot;is_local&quot;: false,
          &quot;primary_color&quot;: null,
          &quot;track&quot;: {
            &quot;album&quot;: {
              &quot;album_type&quot;: &quot;album&quot;,
              &quot;artists&quot;: [
                {
                  &quot;external_urls&quot;: {
                    &quot;spotify&quot;: &quot;https://open.spotify.com/artist/6fOMl44jA4Sp5b9PpYCkzz&quot;
                  },
                  &quot;href&quot;: &quot;https://api.spotify.com/v1/artists/6fOMl44jA4Sp5b9PpYCkzz&quot;,
                  &quot;id&quot;: &quot;6fOMl44jA4Sp5b9PpYCkzz&quot;,
                  &quot;name&quot;: &quot;NF&quot;,
                  &quot;type&quot;: &quot;artist&quot;,
                  &quot;uri&quot;: &quot;spotify:artist:6fOMl44jA4Sp5b9PpYCkzz&quot;
                }
              ],
              &quot;available_markets&quot;: [],
              &quot;external_urls&quot;: {
                &quot;spotify&quot;: &quot;https://open.spotify.com/album/46xdC4Qcvscfs3Ai2RIHcv&quot;
              },
              &quot;href&quot;: &quot;https://api.spotify.com/v1/albums/46xdC4Qcvscfs3Ai2RIHcv&quot;,
              &quot;id&quot;: &quot;46xdC4Qcvscfs3Ai2RIHcv&quot;,
              &quot;images&quot;: [
                {
                  &quot;height&quot;: 640,
                  &quot;url&quot;: &quot;https://i.scdn.co/image/ab67616d0000b273942a0c9ac8f1def7c8805044&quot;,
                  &quot;width&quot;: 640
                },
                {
                  &quot;height&quot;: 300,
                  &quot;url&quot;: &quot;https://i.scdn.co/image/ab67616d00001e02942a0c9ac8f1def7c8805044&quot;,
                  &quot;width&quot;: 300
                },
                {
                  &quot;height&quot;: 64,
                  &quot;url&quot;: &quot;https://i.scdn.co/image/ab67616d00004851942a0c9ac8f1def7c8805044&quot;,
                  &quot;width&quot;: 64
                }
              ],
              &quot;name&quot;: &quot;The Search&quot;,
              &quot;release_date&quot;: &quot;2019-07-26&quot;,
              &quot;release_date_precision&quot;: &quot;day&quot;,
              &quot;total_tracks&quot;: 20,
              &quot;type&quot;: &quot;album&quot;,
              &quot;uri&quot;: &quot;spotify:album:46xdC4Qcvscfs3Ai2RIHcv&quot;
            },
            &quot;artists&quot;: [
              {
                &quot;external_urls&quot;: {
                  &quot;spotify&quot;: &quot;https://open.spotify.com/artist/6fOMl44jA4Sp5b9PpYCkzz&quot;
                },
                &quot;href&quot;: &quot;https://api.spotify.com/v1/artists/6fOMl44jA4Sp5b9PpYCkzz&quot;,
                &quot;id&quot;: &quot;6fOMl44jA4Sp5b9PpYCkzz&quot;,
                &quot;name&quot;: &quot;NF&quot;,
                &quot;type&quot;: &quot;artist&quot;,
                &quot;uri&quot;: &quot;spotify:artist:6fOMl44jA4Sp5b9PpYCkzz&quot;
              }
            ],
            &quot;available_markets&quot;: [],
            &quot;disc_number&quot;: 1,
            &quot;duration_ms&quot;: 248053,
            &quot;episode&quot;: false,
            &quot;explicit&quot;: false,
            &quot;external_ids&quot;: {
              &quot;isrc&quot;: &quot;USUM71907048&quot;
            },
            &quot;external_urls&quot;: {
              &quot;spotify&quot;: &quot;https://open.spotify.com/track/3oLe5ZILASG8vU5dxIMfLY&quot;
            },
            &quot;href&quot;: &quot;https://api.spotify.com/v1/tracks/3oLe5ZILASG8vU5dxIMfLY&quot;,
            &quot;id&quot;: &quot;3oLe5ZILASG8vU5dxIMfLY&quot;,
            &quot;is_local&quot;: false,
            &quot;name&quot;: &quot;The Search&quot;,
            &quot;popularity&quot;: 74,
            &quot;preview_url&quot;: &quot;https://p.scdn.co/mp3-preview/c26b3dedc967f5009451a693ac275e50c6ecb53c?cid=1f51bd6bdbd94e34884f3ec17c0f68ed&quot;,
            &quot;track&quot;: true,
            &quot;track_number&quot;: 1,
            &quot;type&quot;: &quot;track&quot;,
            &quot;uri&quot;: &quot;spotify:track:3oLe5ZILASG8vU5dxIMfLY&quot;
          },
          &quot;video_thumbnail&quot;: {
            &quot;url&quot;: null
          }
        },
        {
          &quot;added_at&quot;: &quot;2021-11-17T07:33:24Z&quot;,
          &quot;added_by&quot;: {
            &quot;external_urls&quot;: {
              &quot;spotify&quot;: &quot;https://open.spotify.com/user/username&quot;
            },
            &quot;href&quot;: &quot;https://api.spotify.com/v1/users/username&quot;,
            &quot;id&quot;: &quot;username&quot;,
            &quot;type&quot;: &quot;user&quot;,
            &quot;uri&quot;: &quot;spotify:user:username&quot;
          },
          &quot;is_local&quot;: false,
          &quot;primary_color&quot;: null,
          &quot;track&quot;: {
            &quot;album&quot;: {
              &quot;album_type&quot;: &quot;album&quot;,
              &quot;artists&quot;: [
                {
                  &quot;external_urls&quot;: {
                    &quot;spotify&quot;: &quot;https://open.spotify.com/artist/3uL4UpqShC4p2x1dJutoRW&quot;
                  },
                  &quot;href&quot;: &quot;https://api.spotify.com/v1/artists/3uL4UpqShC4p2x1dJutoRW&quot;,
                  &quot;id&quot;: &quot;3uL4UpqShC4p2x1dJutoRW&quot;,
                  &quot;name&quot;: &quot;Ghostemane&quot;,
                  &quot;type&quot;: &quot;artist&quot;,
                  &quot;uri&quot;: &quot;spotify:artist:3uL4UpqShC4p2x1dJutoRW&quot;
                }
              ],
              &quot;available_markets&quot;: [],
              &quot;external_urls&quot;: {
                &quot;spotify&quot;: &quot;https://open.spotify.com/album/4pzCKSWYNM2yUWrNvycC6e&quot;
              },
              &quot;href&quot;: &quot;https://api.spotify.com/v1/albums/4pzCKSWYNM2yUWrNvycC6e&quot;,
              &quot;id&quot;: &quot;4pzCKSWYNM2yUWrNvycC6e&quot;,
              &quot;images&quot;: [
                {
                  &quot;height&quot;: 640,
                  &quot;url&quot;: &quot;https://i.scdn.co/image/ab67616d0000b27347fa4895a04fbb517fd42070&quot;,
                  &quot;width&quot;: 640
                },
                {
                  &quot;height&quot;: 300,
                  &quot;url&quot;: &quot;https://i.scdn.co/image/ab67616d00001e0247fa4895a04fbb517fd42070&quot;,
                  &quot;width&quot;: 300
                },
                {
                  &quot;height&quot;: 64,
                  &quot;url&quot;: &quot;https://i.scdn.co/image/ab67616d0000485147fa4895a04fbb517fd42070&quot;,
                  &quot;width&quot;: 64
                }
              ],
              &quot;name&quot;: &quot;Hexada&quot;,
              &quot;release_date&quot;: &quot;2017-09-05&quot;,
              &quot;release_date_precision&quot;: &quot;day&quot;,
              &quot;total_tracks&quot;: 10,
              &quot;type&quot;: &quot;album&quot;,
              &quot;uri&quot;: &quot;spotify:album:4pzCKSWYNM2yUWrNvycC6e&quot;
            },
            &quot;artists&quot;: [
              {
                &quot;external_urls&quot;: {
                  &quot;spotify&quot;: &quot;https://open.spotify.com/artist/3uL4UpqShC4p2x1dJutoRW&quot;
                },
                &quot;href&quot;: &quot;https://api.spotify.com/v1/artists/3uL4UpqShC4p2x1dJutoRW&quot;,
                &quot;id&quot;: &quot;3uL4UpqShC4p2x1dJutoRW&quot;,
                &quot;name&quot;: &quot;Ghostemane&quot;,
                &quot;type&quot;: &quot;artist&quot;,
                &quot;uri&quot;: &quot;spotify:artist:3uL4UpqShC4p2x1dJutoRW&quot;
              }
            ],
            &quot;available_markets&quot;: [],
            &quot;disc_number&quot;: 1,
            &quot;duration_ms&quot;: 124538,
            &quot;episode&quot;: false,
            &quot;explicit&quot;: true,
            &quot;external_ids&quot;: {
              &quot;isrc&quot;: &quot;TCADG1741539&quot;
            },
            &quot;external_urls&quot;: {
              &quot;spotify&quot;: &quot;https://open.spotify.com/track/2Vc6NJ9PW9gD9q343XFRKx&quot;
            },
            &quot;href&quot;: &quot;https://api.spotify.com/v1/tracks/2Vc6NJ9PW9gD9q343XFRKx&quot;,
            &quot;id&quot;: &quot;2Vc6NJ9PW9gD9q343XFRKx&quot;,
            &quot;is_local&quot;: false,
            &quot;name&quot;: &quot;Mercury: Retrograde&quot;,
            &quot;popularity&quot;: 76,
            &quot;preview_url&quot;: &quot;https://p.scdn.co/mp3-preview/7d4cb282d38d48d85e9faedb3ea5e74546281d07?cid=1f51bd6bdbd94e34884f3ec17c0f68ed&quot;,
            &quot;track&quot;: true,
            &quot;track_number&quot;: 4,
            &quot;type&quot;: &quot;track&quot;,
            &quot;uri&quot;: &quot;spotify:track:2Vc6NJ9PW9gD9q343XFRKx&quot;
          },
          &quot;video_thumbnail&quot;: {
            &quot;url&quot;: null
          }
        }
      ],
      &quot;limit&quot;: 100,
      &quot;next&quot;: null,
      &quot;offset&quot;: 0,
      &quot;previous&quot;: null,
      &quot;total&quot;: 2
    },
    &quot;type&quot;: &quot;playlist&quot;,
    &quot;uri&quot;: &quot;spotify:playlist:50uWPcNFdJElMVZWo0IebB&quot;
  }
  </code></pre>
  <p>And this is only for two songs being in the playlist!</p>
  <p>At this point my limited knowledge of python fails me, because I dont know how to proceed from here. All I am looking for is the track name and the corresponding artist.</p>
  <p>So, how do I go through the massive nested list, and only print out the fields Im interested in?</p>