Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit cae2fd5

Browse files
committed
Update is_palindrome non-alphanumeric characters check
1 parent 25d803f commit cae2fd5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/sequences/func.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
"""
55

6-
import string
76
from typing import List, Union
87

98
from calc import get_squares
@@ -38,16 +37,15 @@ def is_palindrome(origin: Union[str, int], /) -> bool:
3837
"""
3938

4039
origin = str(origin).lower()
41-
skip_chars: str = string.punctuation + string.whitespace
4240
left: int = 0
4341
right: int = len(origin) - 1
4442

4543
while left < right:
46-
if origin[left] in skip_chars:
44+
if not origin[left].isalnum():
4745
left += 1
4846
continue
4947

50-
if origin[right] in skip_chars:
48+
if not origin[right].isalnum():
5149
right -= 1
5250
continue
5351

0 commit comments

Comments
 (0)