본문 바로가기
python-algorithm

백준 29766 DKSH 찾기

by 무적김두칠 2023. 11. 16.

https://www.acmicpc.net/problem/29766

 

29766번: DKSH 찾기

첫째 줄에 문자열이 입력된다. 문자열의 길이는 $1\,000$을 넘지 않는다.

www.acmicpc.net

 

1
2
3
4
5
6
7
8
def solution(s):
    return  s.count('DKSH')
 
 
if __name__ == '__main__':
    s = input()
    print(solution(s))
 
cs

Python 문자열에는 count 메소드가 있어서 특정 문자열이 몇번 포함됐는지 셀 수 있습니다.

반응형

'python-algorithm' 카테고리의 다른 글

백준 30676 이 별은 무슨 색일까  (0) 2023.11.23
백준 30033 Rust Study  (0) 2023.11.16
백준 30328 Java Warriors  (0) 2023.11.16
백준 30664 Loteria Falha  (1) 2023.11.16
백준 2751 수 정렬하기 2  (0) 2023.09.12

댓글