Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

search dictionary for value

mydict = {'george':16,'amber':19}
res = dict((v,k) for k,v in mydict.items())
print(res[16]) # Prints george

print(res.get(16))
Comment

search in dict python

dictionary = { "key1" : 1, "name" : "Jordan", "age" : 21 }
for key in dictionary.keys():
    print("the key is {} and the value is {}".format(key, dictionary[key]))
    # or print("the key is",key,"and the value is",dictionary[key])
# OUTPOUT
# the key is key1 and the value is 1
# the key is name and the value is Jordan
# the key is age and the value is 21
Comment

PREVIOUS NEXT
Code Example
Python :: How to Use Python all() Function to Check for Letters in a String using all function 
Python :: basic script 
Python :: replace word in column pandas lambda 
Python :: remove space from string python 
Python :: python get element from dictionary 
Python :: how to find maximum number from python list 
Python :: python text color 
Python :: how to get median mode average of a python list 
Python :: custom django user model 
Python :: how to use dictionaries in python 
Python :: python read video frames 
Python :: pathlib path of current file 
Python :: generate random integers 
Python :: Python Tkinter Message Widget 
Python :: how to allow only for create field in serializer 
Python :: import django concat 
Python :: python async function 
Python :: python if 
Python :: compose functions python 
Python :: add list to list python 
Python :: python hasattribute 
Python :: how to drop column where target column is null 
Python :: insert row at given position in pandas dataframe 
Python :: how to install docx in python 
Python :: remove first item form dictionary python 
Python :: random.sample python 
Python :: count nan values 
Python :: Copying a list using deepcopy() in python 
Python :: find frequency of numbers in list python 
Python :: install python3 in ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =