I have a dictionary like so:
myDict = {'items':
[{'names': [{'longName1', 'shortName1'},
{'shortName2', 'longName2'}]},
{'names': [{'longName3', 'shortName3'},
{'shortName4', 'longName4'}]}]}
Attempting to get the keys (i.e. shortName) in a set Pythonically. I have the following statement, but it's complaining that i
isn't defined. What am I doing wrong?
shortNames = set().union(*(j.values() for j in i["names"] for i in myDict["items"]))
Expected result:
set(['shortName1', 'shortName2', 'shortName3', 'shortName4'])