Python string length | len()

Python Strings

Strings in python are enclosed by either single quotation marks, or double quotation marks.

'Wikitechy' is the same as "Wikitechy".

Python string length | len()

  • len() function is an inbuilt function in Python programming language that returns the length of the string, array, list, tuple, dictionary, etc.
  • You can use len function to optimize the performance of the program. The number of elements stored in the object is never calculated, so len helps provide the number of elements.

Syntax

len(string)

Parameters:

It takes string as the parameter

Return Value:

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


# Python program to demonstrate the use of
# len() method

# Length of below string is 5
string = "wikitechy"
print(len(string))

# Length of below string is 15
string = "Wikitechy wikitechy"
print(len(string))

Output:

9
19

Post navigation

Arrays.sort() in java

What is an Array? Arrays are used to store multiple values in a single variable, instead…

If you like this post you might alo like these

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO