Python 3 Script to Count the Number of Characters in a String Full Project For Beginners

Python 3 Script to Count the Number of Characters in a String Full Project For Beginners

 

Welcome folks today in this blog post we will be counting the number of characters in a string in python. All the full source code of the application is shown below.

 

 

Get Started

 

 

Here we will be using for loop to achieve this task

 

In order to get started you need to make an app.py file and copy paste the following code

 

app.py

 

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));

 

See also  Python PyAutoGUI TypeWriter Omegle API Message Bot to Send out Unlimited Messages to People in Regular Intervals of Time Full Project For Beginners

 

Now if you execute the python script by typing the below command as shown below

 

python app.py

 

 

 

Leave a Reply