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

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 :: How to Crack PDF Files in Python - Python Cod 
Python :: sharpdevelop pause python code 
Python :: how to check if number has decimals python 
Python :: traversing a tree in python 
Python :: extract text from pdf python 
Python :: change a cell in pandas dataframe 
Python :: get list with random numbers python 
Python :: pandas iteration 
Python :: sendgrid send email to multiple recipients python 
Python :: saleor docker development 
Python :: Python Tkinter Text Widget Syntax 
Python :: dice roller in python 
Python :: how to open a dataset in netcdf4 
Python :: how to sort the dataframe in python by axis 
Python :: longest common subsequence python 
Python :: get random number positive or negative python 
Python :: concatenating datfra,esin pandas 
Python :: python private method 
Python :: sendgrid django smtp 
Python :: logging 
Python :: decode binary string python 
Python :: all() python 
Python :: how to pause a python script 
Python :: readlines replace  
Python :: os path splitext 
Python :: fetch row where column is missing pandas 
Python :: how to access variables from a class in python 
Python :: python delete directory contents 
Python :: queryset to list python 
Python :: How to calculate distance without numpy 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =