Dictionary key and values

need help, I need to create a function that input keys and values and check if it exist in the dictionary. I tried dict.keys(), dict.values and dict.items(). How can I check if the inputted key and value is existing in the dictionary?

I need to return True if it exist

I may be wrong but it seems to me homework with no effort. Therefore only idea how one could approach this.

Are you sure you tried dict.items()?

>>> d = {1: 'a', 2: 'b', 3: 'c'}
>>> d.items()
dict_items([(1, 'a'), (2, 'b'), (3, 'c')])
>>> mapping = (2, 'b')
>>> mapping in d.items()
True
>>> mapping = (3, 'd')
>>> mapping in d.items()
False
1 Like

Hi Oliver.

Please tell us what code you tried. “I tried dict.keys()” is not
sufficient. What did you do with dict.keys?

print(dict.keys())

len(dict.keys())

dict.keys() + 1

something else?

Be precise, please, not vague. Show us an actual example of what you
tried.

Hi Aivar,

Thanks for taking time, but I already did accomplished it.

Hi Steven,

Thank you for your reply but I do managed to accomplished it.