diff --git a/letter_digit.py b/letter_digit.py index e69de29..e2d4740 100644 --- a/letter_digit.py +++ b/letter_digit.py @@ -0,0 +1,25 @@ +def letterAndDigit (strIn): + if not strIn: + print "Pass non-empty string" + return {} + else: + length = len(strIn) + digit = 0 + letters = 0 + space = 0 + other = 0 + for ch in strIn: + if ch.isalpha(): + letters += 1 + elif ch.isdigit(): + digit += 1 + elif ch.isspace(): + space += 1 + else: + other += 1 + return {"DIGITS":digit, "LETTERS":letters} + +if __name__ == "__main__": + print letterAndDigit ("") + print letterAndDigit (" ") + print letterAndDigit ("a24terte5y =df") diff --git a/letter_digit.pyc b/letter_digit.pyc new file mode 100644 index 0000000..a5e57eb Binary files /dev/null and b/letter_digit.pyc differ diff --git a/tests/__init__.pyc b/tests/__init__.pyc new file mode 100644 index 0000000..58ff13d Binary files /dev/null and b/tests/__init__.pyc differ diff --git a/tests/test_letterAndDigit.pyc b/tests/test_letterAndDigit.pyc new file mode 100644 index 0000000..cf5498e Binary files /dev/null and b/tests/test_letterAndDigit.pyc differ