Last active
October 4, 2017 04:02
-
-
Save jmquintana79/65c70a84ac36e272f14e to your computer and use it in GitHub Desktop.
dictionary use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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