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:
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']