I am stuck on my python lab from this week. The lab deals with strings and being able to search them, slice them, etc. The part I'm stuck on is as follows:

"You will implement in Python a function matchPat. It will take two arguments, a pattern string and a string, and return a Boolean, which indicates whether or not the pattern matches the initial portion of the string. A wild-card match is represented by an asterisk(*). HINT: You should express the algorithm recursively. Again, a good place to start is nesting the structural pattern. For the wild card, try to translate "zero or more characters" into code. Both logical operators and and or are useful."

So basically, I know where to start and what to do for the code itself, what I am having trouble doing is figuring out how to get the * to match "zero or more characters."

A few quick examples to make the question clear:
>>>matchPat('a*t*r', 'anteaters')
True
>>>matchPat('a*t*r', 'albatross')
True
>>>matchPat('a*t*r', 'artist')
False

This code must be done recursively using if statements and can not include the integrated python function 'in'.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.