New to coding so I’m struggling a bit. I have a list of dictionaries that I need to re-format using the key “year” which is a string. So I know I need to use the int() function but I must not be doing it right. Here is the code:
works_by_year =  for author_dict in works: year = int(author_dict["year"]) if year not in works_by_year: works_by_year["year"] =  works_by_year["year"].append(author_dict)
TypeError: list indices must be integers or slices, not str
Can someone please explain to me what I am doing wrong and how to fix it?