A program in Python that will accept any string and will calculate the number of digits and letters in that string.

In the above Python program to calculate the number of digits and letters in a string we used built-in function isdigit() to calculate the number of digits and isalpha() to calculate the number of letters.

str = input("Input a string")
d=l=0 
for s in str:
    if s.isdigit(): 
        d=d+1
    elif s.isalpha(): 
        l=l+1
    else:
        pass
print("Letters", l)
print("Digits", d)
Sample Output:
Input a string : Hello5World
Letters 10
Digits 1