Answers for "get key from dict"

1

python get keys and values from dict

# using dict.items() to
# get key and value
print ("Dict key-value are : ")
for key, value in test_dict.items():
    print (key, value)
Posted by: Guest on May-13-2021
0

dict ;get a key of a value

myDict={"name":"PythonForBeginners","acronym":"PFB"}
print("Dictionary is:")
print(myDict)
dict_items=myDict.items()
print("Given value is:")
myValue="PFB"
print(myValue)
print("Associated Key is:")
for key,value in dict_items:
    if value==myValue:
        print(key)
Posted by: Guest on October-24-2021
0

get dict keys

def getList(dict):
    return dict.keys()
Posted by: Guest on October-08-2021
-3

find key by value python

print(list(d.keys())[list(d.values()).index(990)])
Posted by: Guest on May-04-2020

Python Answers by Framework

Browse Popular Code Answers by Language