Skip to content

Instantly share code, notes, and snippets.

@singhrahuldps
Created June 1, 2019 04:51
Show Gist options
  • Save singhrahuldps/24ffcf0be56aba232ef8762347202591 to your computer and use it in GitHub Desktop.
Save singhrahuldps/24ffcf0be56aba232ef8762347202591 to your computer and use it in GitHub Desktop.
# this function returns a python dictionary
# which maps each id to a corresponding index value
def list_2_dict(id_list:list):
d={}
for id, index in zip(id_list, range(len(id_list))):
d[id] = index
return d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment