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

find value in dictionary python

k = {1:10,2:20,3:30,4:40}
#idea : print([5,6,7,8][[12,15,47,45].index(15)])
b = list(k.keys())[list(k.values()).index(20)] #find index of 20 => return 2
Comment

PREVIOUS NEXT
Code Example
Python :: openpyxl full tutorial 
Python :: matplotlib increase tick frequency 
Python :: python time function in for loop 
Python :: measure time per line python 
Python :: how to read a csv file in python 
Python :: python no module named 
Python :: how to play video in colab 
Python :: text to audio in python 
Python :: outliers removal 
Python :: root mean squared error python 
Python :: ad background image with tkinter 
Python :: flask tutorials 
Python :: bash python csv to json 
Python :: python using datetime as id 
Python :: pywebcopy 
Python :: print typeof in python 
Python :: how to use global variable in python 
Python :: train_test_split sklearn 
Python :: Python Django Models Unique Rows 
Python :: numpy convert true false to 0 1 
Python :: how to get today weekday in python 
Python :: python replace by dictionary 
Python :: np.percentile 
Python :: numpy array input 
Python :: check remote port is open or not using python 
Python :: numpy check if an array is all zero 
Python :: feature importance naive bayes python 
Python :: can you release a python program to an exe file 
Python :: how to get scrapy output file in csv 
Python :: flask remove file after send_file 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =