Skip to content

Commit e6c66d5

Browse files
committed
fix solution: use equality operator, remove regex
1 parent 395f249 commit e6c66d5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

valid-palindrome/dusunax.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919

2020
class Solution:
2121
def isPalindrome(self, s: str) -> bool:
22-
if s is " ":
22+
if s == " ":
2323
return True
2424

25-
reg = "[^a-z0-9]"
26-
converted_s = re.sub(reg, "", s.lower())
25+
s = s.lower()
26+
converted_s = ''.join(c for c in s if c.isalnum())
2727

2828
return converted_s == converted_s[::-1]
29+

0 commit comments

Comments
 (0)