return a list containing the matching phrases according to the given string (p).
Ignore any digit that is placed after or before the given string.
Whether the first letter is capitalized or not,
if all letters of the word match the given string (p), it is valid.
If it does not match the given string (p) then None.
Example
example 1
find_pattern({ "Phrase1": "COVID-19 is no good", "Phrase2": "COVID-18 is no good", "Phrase3": "COVID-17 is no good" }, "COVID-19") ➞ ["Phrase1 = COVID-19", "Phrase2 = None", "Phrase3 = None"]
example 2
find_pattern({ "Phrase1": "Edabit is great", "Phrase2": "Edabit is very great", "Phrase3": "Edabit is really great" }, "really") ➞ ["Phrase1 = None", "Phrase2 = None", "Phrase3 = really"]
My solution
algorithm
>>get the value of each Phrase >>separate the the value into a list by white space >>store each separated value into list the list name from phase1_list to phase6_list >>check if the given string (p) appear in the each phrase for phrase1 to phrase 6: if the given string (p) appear in the phrase value add that phrase and value into one string add that string to the final list >>return a final list
Top comments (0)