Skip to content

Commit 63aa820

Browse files
author
park.seongbin
committed
1152. 단어의 개수 #9 파이썬
1 parent ee0d250 commit 63aa820

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

class01/1152/bee.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import sys
2+
3+
# 자바스크립트의 readFileSync("/dev/stdin")와 유사한 sys.stdin을 사용하여 접근!
4+
input_str = sys.stdin.read().strip()
5+
words = input_str.split(' ')
6+
7+
count = 0
8+
# 반복문을 사용하고 싶은 경우
9+
# for var in range(start, stop, step) 또는 for var in list 사용
10+
for i in range(len(words)):
11+
if words[i] != '':
12+
count += 1
13+
# 파이썬에서 증가(++)는 +=1
14+
15+
print(count)

0 commit comments

Comments
 (0)