Skip to content

Instantly share code, notes, and snippets.

@dlyapun
Created April 20, 2017 10:30
Show Gist options
  • Save dlyapun/de03f1e9524ce9f19fab6bebb77db392 to your computer and use it in GitHub Desktop.
Save dlyapun/de03f1e9524ce9f19fab6bebb77db392 to your computer and use it in GitHub Desktop.
COMPARE TWO WORDS PYTHON
MISTAKE_COUNTS = 4
def check_word(string_one, string_two):
string_one = string_one.lower()
string_two = string_two.lower()
found_count = len(string_one) - len(string_one) / MISTAKE_COUNTS
result = []
for index in xrange(0, len(string_two)):
not_found, found = 0, 0
try:
for index_two in xrange(0, len(string_one)):
if string_one[index_two] == string_two[index + index_two]:
found += 1
else:
not_found += 1
if found >= found_count:
result.append(found)
except IndexError:
pass
return True if result else False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment