0
Q:

how to accessthe keys of a dictionary in python


# 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} 
  
print(get_key(100)) 
print(get_key(11)) 
0
# Python program to show working  
# of keys in Dictionary 
  
# Dictionary with three keys 
Dictionary1 = {'A': 'Geeks', 'B': 'For', 'C': 'Geeks'} 
  
# Printing keys of dictionary 
print(Dictionary1.keys()) 
  
# Creating empty Dictionary 
empty_Dict1 = {} 
  
# Printing keys of Empty Dictionary 
print(empty_Dict1.keys()) 
1

New to Communities?

Join the community