If I have a large list that I want to create a dictionary out of, what would be the most efficient way of doing this supposing I just want to assign the value as so:
{'item1':'0','item2':'1','item3':'2','itemn':'n-1'}
I've seen a lot on here about just assigning same value to all the keys, but nothing about how to assign the values as I need.
Thanks.
EDIT: The reason I want to do this is because I've been handed someone's code that is atrocious...(not that I'm a skilled programmer by any means), and we have a list of objects that are represented by ID numbers: 5432, 8976, etc etc.
There's a few hundred of them. Well rather than, as the original code does, treat the list as an array, then find its range(len(my_list))
to get an indicial value for each object, I was thinking it might be better to just create a dictionary with keys/values, declare that once and refer to it later rather than recalling the array or -in this case- recreating the array every time. Is that a reasonable idea? I don't know, but I wanted to try it.