• Register

 

Python Program to Count Total Characters in a String

Today we will learn about strings. We use strings more in computer language. Because now I'm talking to you, I'm talking in strings, not numbers. Similarly, when we make big programs.  If so, it is important that we have enough knowledge about strings and the functions used in them. The more we practice, the more we will benefit. Using only strings in the program if we have a paragraph.  My name is Tania. Now I want to know how many times my name appears in this paragraph. I will use the len function in my program. It helps me to know how many times my name appears.  Let's use the concatenate function known as + to connect the string. If I concatenate the string, I can also use a comma, because it also helps us to connect the string.  Let's look at some examples of how we try to find the number of characters in a string.  

Example:

# Python Program to Count Total Characters in a String 
str1 = input("Please Enter your Own String : ") total = 0 i = 0 while(i < len(str1)): total = total + 1 i = i + 1 print("Total Number of Characters in this String = ", total)



           OUTPUT 
Please Enter your Own String : Wellcome to kodlogs 
Total Number of Characters in this String = 18

 

Example :

# Python Program to Count Total Characters in a String
 str1 = input("Please Enter String : ")
 total = 0 for i in str1: total = total + 1 

print("Total Number of Characters in this String = ", total)

More Posts

How to count number of items in list python Tania - May 8
Python find string in file | by kodlogs....... Tania - Apr 17
Python check if an elements is in a list Tania - May 28
Python How many item in a list Tania - Apr 7
Python for each items in a list Tania - Apr 5
Python how to append to a list | by kodlogs Answer's... Tania - Apr 25
Removing element from a list python Tania - Feb 21
Different between list and array in python Tania - May 8
How to increment value in dictionary python Tania - May 8
-repr-in python - by kodlogs Answer's..... Tania - Apr 25