I have a string that is the correct spelling of a word:
FOO
I would allow someine to mistype the word in such ways:
FO, F00, F0O ,FO0
Is there a nice way to check for this ? Lower case should also be seen as correct, or convert to upper case. What ever would be the prettiest.
The builtin module difflib has a get_close_matches function.
You can use it like this:
Notice that it doesn’t match one of your cases. You could lower the
cutoffparameter to get a match: