def invert_actor_dict(actor_dict):
    movie_dict = {}
for actor, movies in actor_dict.items():
    for movie in movies:
        if not movie_dict.has(movie):
            movie_dict[movie] = []
movie_dict[movie].append(actor)
return movie_dict
инвертирующий словарь в python