All Python Tutorial Links

How to get the length of a string using Python?

 Get Length of a String using Python


Hello Programmers!
In this tutorial, I will teach you how to get the length of a string using Python. This is an intermediate concept of python. So let's get started.

Many times we need to get the length of a string in python. The python has a built-in function for that. It is called the len() function. 

Syntax

str = "Python Programming"

len = len(str)

I hope that you have understood what is the syntax of the len() function. But, still if you have any questions, then comment below ;). 

Example

str = "Python Programming"

len = len(str)

print(len)

Output

18


In the above code, we have defined a string. Then we are getting the length of the string and storing it in the len variable. At last, e are printing the len variable. It means that it will print the length of the string.

Congratulations! Now you know how to get the length of a string using python. If you have any confussion then comment below. 

    Happy Coding :)


python,python strings,python tutorial,finding the length of a string,strings in python,learn python,python string length,finding the length of a python string,find the length of a string in python,python programming,length of string in python,length of a string,find length of a string,lenght of a string python,how to find length of string in python,string methods in python,python 3,python string processing,write a python program to calculate the length of a string,python for beginners

Comments