Find dictionary items whose key matches a substring
dictionary, key, python, substring
Solution
[value for key, value in programs.items() if 'new york' in key.lower()]
Problem
I have a large dictionary constructed like so: ``` programs['New York'] = 'some values...' programs['Port Authority of New York'] = 'some values...' programs['New York City'] = 'some values...' ... ``` How can I return all elements of `programs` whose key mentions "new york" (case insensitive)? In the example above, I would want to get all the three items. EDIT: The dictionary is quite large and expected to get larger over time.