users = {'196': ('110', '1'), '186': ('269', '1'), '22': ('68', '4'), '196': ('650', '3')}
movies = {'110': 'Operation Dumbo Drop (1995)', '186': 'Blues Brothers, The (1980)', '269': 'Full Monty, The (1997)', '68': 'Crow, The (1994)', '650': 'Seventh Seal, The (Sjunde inseglet, Det) (1957)'}
My code to create a nested dictionary with keys a unique list of users (keys from users) but using keys from movies to replace values of movies IDs (first item of value list from users) and keeping scores (second item of value list from users) is:
users_preference = {k: list(set().union((*map(lambda x: [x for x in movies.values()], v[0])) )) for k, v in users.items() }
But this returns all movies for each user, and I don't know how to add scores to this. Could you please help? Thank you.
The expected output is similar to:
users_preference = {'196': {'Operation Dumbo Drop (1995)': '1', 'Seventh Seal, The (Sjunde inseglet, Det) (1957)': '3'}