python - Create a list from multiple attributes -


let's have list of dicts or objects, looks this:

[     {'score': 5, 'tally': 6},     {'score': 1, 'tally': none},     {'score': none, 'tally': none}, ] 

what pythonic , concise way of creating list of ‘score’s , ‘tally’s not none? result following:

[5, 6, 1 ] 

try concise solution, using list comprehensions:

lst = [{'score': 5, 'tally': 6},        {'score': 1, 'tally': none},        {'score': none, 'tally': none}]  [v m in lst v in m.values() if v not none] => [6, 5, 1] 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -