Skip to content
Related Articles

Related Articles

Python string length | len()
  • Difficulty Level : Basic
  • Last Updated : 07 Jan, 2018

len() function is an inbuilt function in Python programming language that returns the length of the string.

Syntax:

len(string)

Parameters:
It takes string as the parameter.

Return Value:



It returns an integer which is the length of the string.

Below is the Python implementation of the len() method.




# Python program to demonstrate the use of
# len() method  
  
# Length of below string is 5
string = "geeks" 
print(len(string))
  
# Length of below string is 15
string = "geeks for geeks" 
print(len(string))

Output:

5
15

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :