Answers for "print python dictionary keys and values"

9

print key of dictionary python

for key, value in mydic.items() :
    print (key, value)
Posted by: Guest on June-03-2020
7

printing python dictionary values

#print keys and values from the dictionary

for k, v in dic.items():
  print(k, v)
Posted by: Guest on April-09-2020
5

how to get the key for a value in 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))
Posted by: Guest on June-12-2020
1

python dict print keys

print(dictionary.items()) #prints keys and values
print(dictionary.keys()) #prints keys
print(dictionary.values()) #prints values
Posted by: Guest on February-20-2021

Code answers related to "print python dictionary keys and values"

Python Answers by Framework

Browse Popular Code Answers by Language