Im trying to create a dictionary with a dictionary comprehension. The dict should look like this:
So far I tried:
player_objects = ['list', 'of', 'player_objects']
extended_data = {player_name:{'Money':100, 'Items'=['Item1', 'Item2']}}
data = {player_object:extended_data.get(player).get('Items') for player in extended_data for player_object in player_objects}
#expected output:
data = {player_object:['list', 'of', 'items']}
But this returns a dict where all players have the Items
of the last player, I also figured out this comes from for player_object in player_objects
.
Can I get the dict I want only with dictionary comprehension?