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
Comments
Post a Comment