I want a function which will take value from user and display the respective key of the dictionary
Ex. d={'name':'ayush','age':21,'Hobby':'cricket'}
Please enter the value : ayush Key related to entered value is: name
I want a function which will take value from user and display the respective key of the dictionary
Ex. d={'name':'ayush','age':21,'Hobby':'cricket'}
Please enter the value : ayush Key related to entered value is: name
Here is one option with list-comprehension:
[k for k, v in d.items() if v == 'ayush']
# ['name']