I got confused between Representations. But I checked, my output is "class tuple"
My code is:
for key, value in analysis.items():
tvi = (key, {k:v for k, v in value.indicators.items() if k in indica})
TVA = print(tvi)
And I had a list of multiple tuples:
('James',{'hair':'black','eye':'brown'})
('Michael',{'hair':'brown','eye':None})
('Robert',{'hair':'red','eye':'black'})
('Washington',{'hair':'grey','eye':'grey'})
('Jefferson',{'hair':'brown','eye':''})
I want to convert into a big list like that:
[
('James',{'hair':'black','eye':'brown'}),
('Michael',{'hair':'brown','eye':None}),
('Robert',{'hair':'red','eye':'black'}),
('Washington',{'hair':'grey','eye':'grey'}),
('Jefferson',{'hair':'brown','eye':''})
]
CodePudding user response:
You can do this with list comprehension,
[(key, {k:v for k, v in value.indicators.items() if k in indica})
for key, value in analysis.items()]