It is important to find and understand the algorithm of a problem before start writing the codes. You need to realize that programming is not such a thing that can not be learned by heart. You need to be logical first and pull out the algorithm before anything else. Let’s write the algorithm for this particular problem and then we’ll write the codes.
# Prompt the user to enter the string and then read it, and store it in a variable.
# Initialize a counter variable and assign zero to it. We will increment the value by 1 every time if we found any character in the given string.
# We will use a loop and iterate over the string.
# Check for each character If we get a blank character or not. If it is not a blank character, increment the value of the counter variable by 1.
# After completing the iteration, we’ll print the value of the counter. Hence this variable is holding our total number of characters.
input_string = input("Enter a string here: ")
counter = 0
for n in input_string :
if n.isspace() != True:
counter = counter + 1
print("Total number of characters in the String is: ",counter)
Keep solving. Thanks.