0

I'm trying to write a function that matches strings to a 'target' string if they're identical except for one letter. E.g. if I'm looking for 'astring' and I pass the function on 'bstring', 'astr1ng', 'astiing', etc. I want them to return 'astring'.

I'm just looking at strings of identical length (I've got a rough function using issubset() for strings of different length). The idea is to fix obvious typos in manually entered data.

I was thinking it could look something like (in words, not code): 'if 'astring' == 'xstring' for any x, return xstring (and also for axtring, asxring, etc.). But then it gets more complicated if I have lots of target strings of different length.

How could I approach this? Perhaps the regex module has something? Thanks

Dan
  • 1,575
  • 1
  • 11
  • 17

0 Answers0