python-algorithm

백준 9771 Word Searching

무적김두칠 2023. 2. 24. 17:58

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
반응형