728x90
반응형
[Python] 파이썬 문자열 영문자, 숫자 판별하기 & 소문자로 변환하기 - isalnum, lower
isalnum 함수 isalnum()는 영문자, 숫자 여부를 판별하는 함수 lower 함수 모두 소문자로 변환한다. class Solution: def isPalindrome(self, s: str) -> bool: strs: Deque = collections.deque() for char in s: if char.isalnum(): #영문자, 숫자 여부를 판별 strs.append(char.lower()) # 모두 소문자 변환 while len(strs) > 1: if strs.popleft() != strs.pop(): return False return True 출처 파이썬 알고리즘 인터뷰 (글 : 박상길 그림 : 정진호) [책만]
Python
2020. 10. 3. 10:00
728x90
반응형