Skip to content

Instantly share code, notes, and snippets.

@jmquintana79
Last active October 4, 2017 04:02
Show Gist options
  • Save jmquintana79/65c70a84ac36e272f14e to your computer and use it in GitHub Desktop.
Save jmquintana79/65c70a84ac36e272f14e to your computer and use it in GitHub Desktop.
dictionary use
# example
d={'var1':1, 'var2':2}
# GET INDEX AND VALUES
print d.keys() # ['var1', 'var2']
print d.values() # [1, 2]
# FIND INDEX BY VALUE
mydict = {'george':16,'amber':19}
print(list(mydict.keys())[list(mydict.values()).index(16)]) # Prints george
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment