Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Build a dict in python - 2.6 syntax vs. 2.7
data = ['a', 'b', 'c']
# Python v2.7
my_dict = {key: i for i, key in enumerate(data)}
# Python v2.6
my_dict = dict((key, i) for i, key in enumerate(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.