본문 바로가기
python-algorithm

백준 9771 Word Searching

by 무적김두칠 2023. 2. 24.

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

 

9771번: Word Searching

The first line contains a single word to search. A word contains at most 20 characters. The next line and the rest is a text to search for that word. The text can contain up to 100 lines including blank lines. No line exceeds 250 characters. A word cannot

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
10
11
12
13
if __name__ == '__main__':
    target = input()
    answer = 0
    while True:
 
        try:
            s = input()
            answer += s.count(target)
        except:
            break
 
    print(answer)
 
cs
반응형

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

백준 26575 Pups  (0) 2023.02.27
백준 26471 Farma  (0) 2023.02.24
백준 27541 末尾の文字 (Last Letter)  (0) 2023.02.24
leetcode 232. Implement Queue using Stacks  (0) 2023.02.23
leetcode 739. Daily Temperatures  (0) 2023.02.23

댓글