Count Digit Letter


5.  Write a python program that accepts a string and calculate the number of digits and letter.


#Solution:

s = input("Input a string")
d=l=0
for c in s:
    if c.isdigit():
        d=d+1   
    elif c.isalpha():
        l=l+1    
    else:
        pass

print("Letters",l)
print("Digits",d)




No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...