[Solved] using “?” as a stand-in for a single letter
If you want to avoid regular expressions altogether and need to support only that single case illustrated in your post, then this should work: def match(string, pattern): if len(string) != len(pattern): return False for s, p in zip(string, pattern): if s != p and p != ‘?’: return False return True Execution example: >>> match(‘ABC’, … Read more