import pytest def isPalindrome(s: str): s = ''.join(ch for ch in s if ch.isalnum()).lower() if s == '': return True lens = len(s) p, q = 0, lens - 1 while p < lens or q > 0: if p >= q: return True elif s[p] == s[q]: p += 1 q -= 1 else: return False @pytest.mark.parametrize( "s, expect", [ ("", True), (".", True), ("aa", True), ("A man, a plan, a canal: Panama", True), ("a123a", False) ] ) def test_cases(s, expect): assert isPalindrome(s) == expect