[1152번] 단어의 개수 python

HYEOB KIM·2023년 6월 2일
0

algorithm

목록 보기
33/44

코드 풀이

[1152번] 단어의 개수

import sys

s = sys.stdin.readline()
cnt = 0
status = 0

for i in s:
    if i != ' ' and i != '\n':
        if not status:
            status = 1
            cnt += 1
    else:
        status = 0

print(cnt)
profile
Devops Engineer

0개의 댓글