Pages

Wednesday 9 September 2015

CodeEval - Clean up the words - Easy

import sys

test_cases = open(sys.argv[1], 'r')
for test in test_cases:
    sol=""
    for char in test:
        if char.isalpha():
            sol += char
        else :
            sol += " "
    sol = sol.strip()
    words = sol.split()
    sol = ""
    for i in range(len(words)):
        if i > 0 :
            sol += " "
        sol += words[i].lower()
    print sol

test_cases.close()

No comments:

Post a Comment