I have created a simple py quiz and now want to develop my program. Being dyslexic I get rather frustrated when I have come really close to matching a word but it is just not quite spelt right.
Therefore I have written the function below to check for approximate spelling of a word based on the following rules: the first two letters must match, the last letter must match and the users answer is within 1 character, plus or minus, of the correct answer.
The code works but I am sure it can be simplified using a regular expr . I have had a look at a few tutorials but now stuck.
word= paris
my attempt to match [p,a] {3:5} [s]
def closeMatch():
word=input('input your word here')
wordLen=len(word)
lowWord=wordLen-1
highWord=wordLen+1
frontSplit=(word[0:2])
backSplit=(word[-1])
myWord=input('input the word you want to test')
print('this is the word you entered ' , myWord)
myWordLen=len(myWord)
myWordFSplit=(myWord[0:2])
myWordBSplit=(myWord[-1])
if myWord==word:
print('Correct')
elif myWordFSplit==frontSplit and myWordBSplit==backSplit and myWordLen>=lowWord and myWordLen<=highWord:
print('Nearly correct ' , myWord , ' has at least the first 2 and last letters the same')
print('Also the length of ' , myWord , ' is within one character, plus or minus, of the the word ' , word )
else:
print('Incorrect')
closeMatch()