Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Concat only values in list of dictionary

I’d like to concat only values for list of dict.

Input :

a = [
    {'class': 'A', 'number': '1'}, 
    {'class': 'B', 'number': '2'},
    {'class': 'C', 'number': '3'},
]

Expected Output:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

b = [
    'A.1',
    'B.2',
    'C.3'
] 

Is there 1 line statement for this?

>Solution :

This code can do it easily and also ensure to join all the values of the dictionary.

[".".join(i.values()) for i in a]
# result:
['A.1', 'B.2', 'C.3']
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading