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


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

Solution

s = input()
d={"DIGITS":0, "LETTERS":0}
for c in s:
    if c.isdigit():
        d["DIGITS"]+=1
    elif c.isalpha():
        d["LETTERS"]+=1
    else:
        pass
print("LETTERS", d["LETTERS"])
print("DIGITS", d["DIGITS"])



List all Python Programs