Skip to content

TypeScript code snippet – How to make a dictionary of indices and lists python?

>>> lst = ['A','B','C']
>>> {k: v for v, k in enumerate(lst)}
{'A': 0, 'C': 2, 'B': 1}
See also  How to subset a dataframe in Python based on multiple categorical values?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.