[issue37988] Issue found during language name processing in a list

Terry J. Reedy report at bugs.python.org
Fri Aug 30 21:17:42 EDT 2019


Terry J. Reedy <tjreedy at udel.edu> added the comment:

This code derived from the blurry image

lst = ['malaysian', 'malayalam', 'aaaaaaaaa']
ip = input('word ')
li = len(ip)
miss = 0
for word in lst:
    if len(word) == li:
        for j in range(li-1):  # skip last because of lookahead
            if word[j] != ip[j] and word[j+1] != ip[j]:
                 miss += 1
        if miss < li/2:
            print(word)

run with 3.8.0b4 on Win10 in IDLE prints the expected output.

word malayalam
malaysian
malayalam

I leave it to you to find out why you got something different and to play with variations. Please direct any questions to python-list or similar forums, as they will almost certainly be off-topic here.  And do follow the advice about question format and providing code as text.

Steven, the code ran without error in PyCharm, but gave no matches.  I presume that the 'error' was not matching 'malaysian' even though the miss count 4 is less than 4.5.  I must have corrected something when reading the blurs and polishing the code.

----------
nosy: +terry.reedy
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37988>
_______________________________________


More information about the Python-bugs-list mailing list