반응형
Write a function that checks if a given string (case insensitive) is a palindrome.
Solution:
def is_palindrome(s):
target = s.lower()
for i in range(len(target)//2):
if target[i] != target[-i-1]:
return False
return True
def is_palindrome(s):
s = s.lower()
return s == s[::-1]
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1021. USD => CNY (0) | 2022.10.21 |
---|---|
1020. Convert a string to an array (0) | 2022.10.20 |
1018. Find the smallest integer in the array (0) | 2022.10.18 |
1017. Enumerable Magic - Does My List Include This? (0) | 2022.10.17 |
1016. Multiplication table for number (0) | 2022.10.17 |