Created
April 20, 2017 10:30
-
-
Save dlyapun/de03f1e9524ce9f19fab6bebb77db392 to your computer and use it in GitHub Desktop.
COMPARE TWO WORDS PYTHON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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