How do I add multiple tuples and convert into only list

Question:

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':''})
        ]
Asked By: HK Py

||

Answers:

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()]
Answered By: Rahul K P
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.