Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

access key through value python

mydict = {'george': 16, 'amber': 19}
print(list(mydict.keys())[list(mydict.values()).index(16)])  # Prints george
Comment

access key through value python


dictionary = {'george': 16, 'amber': 19}
search_age = input("Provide age")
for name, age in dictionary.items():  # for name, age in dictionary.iteritems():  (for Python 2.x)
    if age == search_age:
        print(name)

Comment

PREVIOUS NEXT
Code Example
Python :: django count all objects 
Python :: télécharger librairie avec pip 
Python :: change index function for class python 
Python :: check if input is pandas dataframe 
Python :: django login required class based views 
Python :: how to create a numpy array linspace in python 
Python :: instance variable python 
Python :: python Cerberus 
Python :: what is cpython 
Python :: no of words in a string in python 
Python :: how to add user input for a question python 
Python :: # add keys to existing dictionary 
Python :: how to uninstall python 
Python :: python 3 documentation 
Python :: Sorting a list using a named function 
Python :: last element of python list 
Python :: create database tables python 
Python :: pandas unstring list 
Python :: scrapy access settings from spider 
Python :: create smtp server python 
Python :: install requests-html with conda 
Python :: speak by a discord bot in python 
Python :: fastest way to compute pair wise distances python 
Python :: Using replace() method to remove newlines from a string 
Python :: variable bound to a set python 
Python :: get raster corners python 
Python :: minio python create bucket 
Python :: docker run python 
Python :: come fare aprire una pagina web python 
Python :: how to check if element is in list python 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =