Wednesday, October 28, 2015

Write a program that accepts a sentence and calculate the number of letters and digits.

#Question 13
#Level 2

#Question:
#Write a program that accepts a sentence and calculate the number of letters and digits.
#Suppose the following input is supplied to the program:
#hello world! 123
#Then, the output should be:
#LETTERS 10
#DIGITS 3

a=raw_input()
letters=0
digits=0
for c in a:
    if c.isdigit():
        digits = digits + 1
    else:
        letters=letters + 1

print "Letters s" ,letters
print "Digits" ,digits

No comments:

Post a Comment