How to search if dictionary value contains certain string in Python

Searching if a certain string is in a dictionary value, where the values are a list of strings, results in a list printing the values containing that string.

Solution for How to search if dictionary value contains certain string in Python : You can use dict.values() to search if dictionary value contains certain string Use dict.values() to get a list of the values in the dictionary. Create a for-loop to iterate this list of values. Use an if-statement to check if the certain string is in the values.

Use list comprehension for a more compact implementation.

a_dict = { "a" : ["1", "3"], "b" : ["3","4"], "c": ["5", "6"]}


how-to-search-if-dictionary-value-contains-certain-string-in-python