How To Get The Count Of Characters In A String

    #INPUT STRING AND TELL IT'S         DETAILS



print('DETAILS OF A STRING')

w=input('\nEnter a word/sentence :-')
alp=dig=spc=spl_ch=0

for i in w:

    if(i.isalpha()):
        alp+=1

    elif(i.isdigit()):
        dig+=1

    elif(i.isspace()):
        spc+=1

    else:
        spl_ch+=1

print('\nIn The Given String,','\n Number Of Alphabets = ',alp,'\n Number Of Digits = ',dig)
print(' Number Of Spaces = ',spc,'\n Number Of Special Characters = ',spl_ch)
print('Total = ',len(w))



Made By :-
         Nilay Saraf 


Index

1. isalpha() - It is used to count number of alphabets in                                        a string.


2. isdigit()- It is used to count number of digits in a                                             string.


3. isspace()- It is used to count number of spaces in a                     string. 


Comments

Popular Posts