Python string length | len()

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

5
15


My Personal Notes arrow_drop_up

Striver(underscore)79 at Codechef and codeforces D

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.