Problem scenario
You want to write a palindromic testing program without importing any modules that ignores a string’s punctuation or spaces. What do you do?
Solution
Use this program:
def is_palindrome(s: str) -> bool:
# i moves forward, and j moves backward
i, j = 0, len(s) -1
while i < j:
while not s[i].isalnum() and i < j:
i += 1
while not s[j].isalnum() and i < …