Answers for "python convert list to dict with index"

1

python convert list to dict with index

>>> lst = ['A','B','C']
>>> {k: v for v, k in enumerate(lst)}
{'A': 0, 'C': 2, 'B': 1}
Posted by: Guest on April-26-2021

Code answers related to "python convert list to dict with index"

Python Answers by Framework

Browse Popular Code Answers by Language