Given a string that other than letters, numbers, and space if any characters are there
print the count of those characters.
Example
Input: aaa34@raj?where454/
Output: 3
string = "The best of both worlds";
count = 0;
#Counts each character except space
for i in range(0, len(string)):
if(string[i] != ' '):
count = count + 1;
#Displays the total number of characters present in the given string
print("Total number of characters in a string: " + str(count))
Comments
Leave a comment