Question: Write a recursive function called quasi _ palindrome in a file called quasipal.py which will test for quasi - palindromes ( as described below )
Write a recursive function called quasipalindrome in a file called quasipal.py which will test for quasipalindromes as described below
A palindrome is a word spelled the same forwards and backwards, for instance "racecar" or "tacocat" which of course is a real word.
Most sequences of letters like abcdefg are not palindromes. Let's introduce a nearby concept where we talk about a quasipalindrome.
A quasipalindrome of type is a word where it would be a palindrome if we could change one letter for instance: abcdba would be the palindrome abccba or abddba if we could change either one of those letters. However it is not a palindrome itself.
A quasipalindrome of type is a word where it is away from being a palindrome. For instance abczxa is away from being a palindrome.
Write a function called:
def quasipalindromeword errors:
Where word is a string and errors is the maximum number of errors allowed. Determine if a word is a quasipalindrome of type N where N is the number of errors allowed. Your function should return True or False.
Hint: Try to think of using slices to go from one level of the string to another.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
