U
U
usyginso2021-12-12 11:48:12
Python
usyginso, 2021-12-12 11:48:12

How to convert such a list to a dictionary?

Given a list in the following format:
["p=4", "d=5", "h=7"]
How to convert it to a dictionary in the format:
{"p": "4", "d": "5", "h": "7"}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-12-12
@0xD34F

dict(n.split('=') for n in arr)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question