코테/Python기법

str_row = "".join(i).split("0")#0 0 1 1 1 형태#'' '' '111'로 변환
zip(list1, list2)# 1 2 3# "a" "b" "c"# 1, "a"# 2, "b"# 3, "c"#list로 감싸면 list 변환 가능
import redef isPallindrome(s : str) -> bool: s= s.lower() print(s) s= re.sub('[^a-z0-9]','',s) print(s) return s == s[::-1]print(isPallindrome("race A car"))# race a car# raceacar# False
N, *arr = map(int, input().split())print(N, arr)
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd' ]alpha = list(set(alpha))print(alpha)
import reparagraph = "Bob hit a ball, the hit BALL flew far after ir was hit."banned = ['hit']# 단어 문자 아닌 것은 ' ' (공백으로 치환) 하고 소문자로 변경후 , banned가 아닌 것이 리스트로 반환words = [ word for word in re.sub(r'[^\w]', ' ', paragraph).lower().split() if word not in banned]print(words)
류가든
'코테/Python기법' 카테고리의 글 목록