Question: ?*** NO ITERATION PLEASE *** Write a module called advancedmatch.py recursive function called match(pattern, word) that can be used to determine if a given pattern

?*** NO ITERATION PLEASE ***

Write a module called advancedmatch.py recursive function called match(pattern, word) that can be used to determine if a given pattern matches a given word. In this case, a pattern consists of letters and ? and * wildcards. A ? wildcard matches any letter at the corresponding position in the word. A * wildcard matches zero or more letters at the corresponding position in the word. Enter a pattern (or 'q' to quit):

l*ad

Enter a word:

launchpad

It's a match.

Enter a pattern (or 'q' to quit):

*ad

Enter a word:

lead It's a match.

Enter a pattern (or 'q' to quit):

**ad

Enter a word:

lard

They don't match.

Enter a pattern (or 'q' to quit):

q

HINTS: ? We now have an extra base case: if word is and pattern is * then return True. ?

Generally, when the first character of the pattern is a * wildcard, try to

(i) match the rest of the pattern to the word, or

(ii) match the pattern to the rest of the word.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!