Q. Write a program to input line(s) of text from the user until enter is pressed. Count the total number of characters in the text (including white spaces), total number of alphabets, total number of digits, total number of special symbols and total number of words in the given text. (Assume that each word is separated by one space).


Answer :-


s = input("Input a line :- ")
alpha = 0
digit = 0
symbol = 0
word = s.count(" ") + 1

for i in s :
    if i.isalpha() :
        alpha += 1
    elif i.isdigit():
        digit += 1
    else :
        symbol += 1

print("Total Number of character is ",len( s))
print("total number of alphabets :-",alpha)
print("total number of digits" , digit)
print( "total number of special symbols :-" , symbol )
print("total number of words" , word)

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post