Skip to content

Python code snippet – How to get key of a particular value in dictionary using index?

# function to return key for any value 
def get_key(val): 
    for key, value in my_dict.items(): 
         if val == value: 
             return key 
    return "key doesn't exist"
# Driver Code 
my_dict ={"java":100, "python":112, "c":11} 
See also  PHP code snippet - How to prevent user to add duplicate card in stripe using laravel?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.