PPA-4
Question
Write a function named value_to_keys
that accepts a dictionary D
and a variable named value
as arguments. It should return the list of all keys in the dictionary that have value equal to value
. If the value
is not present in the dictionary, the function should return the empty list.
- You do not have to accept input from the user or print the output to the console. You just have to write the definition of the function.
- The keys inside the list could be in any order.
Hint
Approach-1
Iterate over the keys:
Approach-2
Iterate over the key-value pairs
This should be sufficient for you to complete the code.