Counter (2) 썸네일형 리스트형 [24.06.19] 99클럽 코테 스터디 31일차 TIL - Counter 1. Counter표준 라이브러리인 collections 모듈에 포함된 클래스이다.counter는 주어진 시퀀스나 이터러블의 요소를 키로, 요소의 개수를 값으로 저장한다.counter는 딕셔너리를 extend한 자료형으로, 딕셔너리의 내장함수를 모두 사용가능하다. 1.1 기본 사용법from collections import Countertext = "hello world"counter = Counter(text)print(counter)# Counter({'l': 3, 'o': 2, 'h': 1, 'e': 1, ' ': 1, 'w': 1, 'r': 1, 'd': 1}) 1.2 Counter 주요 메소드1.2.1 update()기존 counter 객체에 새로운 데이터를 추가하거나 기존 데이터의 개수를 증가.. [Python] 819. Most Common Word leetcode.com/problems/most-common-word/ Most Common Word - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이 class Solution: def mostCommonWord(self, paragraph: str, banned: List[str]) -> str: words = [word for word in re.sub(r'[^\w]', ' ', paragraph).lower().split() if word not i.. 이전 1 다음