aboutsummaryrefslogtreecommitdiff
path: root/challenge-083/gugod/python/ch-1.py
blob: 18e4b638e563b60e036f60323b44f42c8d094289 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env python3
import sys

def wordsLength(s):
    s = s.strip(' ')
    p = s.find(' ')
    return 0 if p == -1 else (s.rfind(' ') - p - s.count(' ') + 1);

# print(wordsLength("hello namaste konnichiwa hello")); # 17
# print(wordsLength("hello namaste")); # 0
# print(wordsLength("hello"));    # 0

print("# " + sys.argv[1]);
print(wordsLength(sys.argv[1]));