pass 88 and 125 easy

This commit is contained in:
2024-05-24 19:37:30 +02:00
parent af4efbce2f
commit 1176c423e8
2 changed files with 67 additions and 0 deletions

25
125-240524-pass/main.py Normal file
View File

@@ -0,0 +1,25 @@
def isPalindrome(s: str) -> bool:
tmp = s
tmp = tmp.lower()
def is_char(ch):
if (ch >= 'a' and ch <= 'z') or (ch >= '0' and ch <= '9'):
return True
return False
exp = []
for lt in tmp:
if is_char(lt):
exp.append(lt)
length = len(exp)
for index, ele in enumerate(exp):
if(exp[index] != exp[length - index - 1]):
return False
return True
s = 'A man, a plan a canal: Panama'
print(isPalindrome(s))
s = " "
print(isPalindrome(s))
s = "race a car"
print(isPalindrome(s))
s = "0P"
print(isPalindrome(s))