컴공생의 다이어리

[파이썬, Python] 백준 1543번 : 문서 검색 본문

Development/Algorithm & Coding Test

[파이썬, Python] 백준 1543번 : 문서 검색

컴공 K 2022. 4. 20. 00:01

백준 1543번 : 문서 검색

(문제 바로가기)

 

 

내 코드

import sys

document = sys.stdin.readline().strip()
find_txt = sys.stdin.readline().strip()

len_find_txt = len(find_txt)
index, count = 0, 0

while True:
    index = document.find(find_txt, index)
    if index == -1:
        break
    count += 1
    index += len_find_txt

print(count)

 

 

728x90
Comments