I'm writing a program that makes a dictionary where there are keys with values that have long text sentences.
The goal of the program is for me to text a number, Python scrapes the website and compiles a dictionary from the scrape, and then searches the values for the string from my text. As an example, let's say the dictionary looks like as follows:
myDict = {"Key1": "The dog ran over the bridge",
"Key2": "The cat sleeps under the rock",
"Key3": "The house is dark at night and the dog waits"}
Let's say I want to search the values and return the key to me that has the relevant string. So if I text 'dog' to the number, it scans the dictionary for all values that have 'dog' and then returns the key with the relevant value, in this case 'Key1' and 'Key3'.
I've tried a few methods of doing this from elsewhere on stack exchange, such as here: How to search if dictionary value contains certain string with Python
However, none of those worked. It either gives me only the first Key regardless of the string, or it returned an error message.
I'd like it to be case insensitive, so I imagine I need to use re.match, but I'm having trouble utilizing regex with this dict and getting any useful returns.