Answer to Question #265038 in Python for Raj

Question #265038

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


1
Expert's answer
2021-11-14T09:21:06-0500
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))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS