Sep-26-2020, 09:16 PM
Let's figure out the structure you want. The "director_known_for" bit is right now a list, with odd elements. Maybe instead of a list you want another dict, so you can index by director? Then those values will be another dict? Is the stuff after "director1" supposed to be the value? If so, then (with some f-string reformatting), maybe this is what you're looking for?
tmdb_url = "https://themoviedb.org/movie" director_known_for = { director1: {movie1: f"{k['title']} {k['release_date']} {tmdb_url} {k['id']}", movie1: f"{k['title']} {k['release_date']} {tmdb_url} {k['id']}", }, }Why are the elements like
k['title']
used repeatedly? Since k
isn't changing, this will be the same in all the items.