Leeee1111 / testjudge-asia

0 stars 0 forks source link

B0501 判斷是否為迴文 #39

Open Leeee1111 opened 1 week ago

Leeee1111 commented 1 week ago
def is_palindrome(s):
    s = ''.join(c.lower() for c in s if c.isalnum())
    return s == s[::-1]

input_string = input()

if is_palindrome(input_string):
    print("YES")
else:
    print("NO")
Leeee1111 commented 1 week ago
a=str(input())
if a[:len(a)//2] == a[:(len(a)-1)//2:-1]:
    print("YES")
else:
    print("NO")