1234567891011121314 |
- # This problem was to check (case insensitively) if a given str is a palindrome
-
- class Solution:
- def isPalindrome(self, s: str) -> bool:
- newString = ""
- for c in s:
- if ord(c.lower()) <= 122 and ord(c.lower()) >= 97 or (ord(c) >= 48 and ord(c) <= 57):
- newString += c.lower()
-
- return newString == newString[::-1]
-
- s = Solution()
- print("Expect: True")
- print("Got:", s.isPalindrome("aba"))
|