Skip to content

Commit 3bf31e2

Browse files
committed
added 0004
1 parent 93bddfb commit 3bf31e2

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

ailurus1991/.DS_Store

6 KB
Binary file not shown.

ailurus1991/0004/input.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fff sdf sdf
2+
sdf
3+
sdf
4+
sa
5+
df
6+
as
7+
df
8+
sdSS

ailurus1991/0004/main.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = 'jinyang'
5+
6+
7+
def calcWords(path):
8+
file = open(path, 'r')
9+
inputStr = file.read()
10+
wordsNum = 0
11+
for i in inputStr:
12+
if i == ' ' or i == '\n':
13+
wordsNum += 1
14+
15+
file.close()
16+
print wordsNum + 1
17+
18+
if __name__ == '__main__':
19+
calcWords('input.txt')

0 commit comments

Comments
 (0)