Skip to content

Instantly share code, notes, and snippets.

@kerenskybr
Created October 6, 2022 13:49
Show Gist options
  • Save kerenskybr/668dfc4c6054c5b9264f40aecef9b4ce to your computer and use it in GitHub Desktop.
Save kerenskybr/668dfc4c6054c5b9264f40aecef9b4ce to your computer and use it in GitHub Desktop.
Another way to populate a dict when using enumerate
# Another way to populate a dict when using enumerate
my_dict = {}
my_string = 'Something'
for i, my_dict[i] in enumerate(my_string):
pass
# Output:
# {0: 'S', 1: 'o', 2: 'm', 3: 'e', 4: 't', 5: 'h', 6: 'i', 7: 'n', 8: 'g'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment