Message350903
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. |
|
Date |
User |
Action |
Args |
2019-08-31 01:17:43 | terry.reedy | set | recipients:
+ terry.reedy, steven.daprano, xtreak, AjaySyam |
2019-08-31 01:17:42 | terry.reedy | set | messageid: <1567214262.93.0.388757551269.issue37988@roundup.psfhosted.org> |
2019-08-31 01:17:42 | terry.reedy | link | issue37988 messages |
2019-08-31 01:17:42 | terry.reedy | create | |
|