Python String len() Method

Advertisements


Description

The method len() returns the length of the string.

Syntax

Following is the syntax for len() method:

len( str )

Parameters

  • NA

Return Value

This method returns the length of the string.

Example

The following example shows the usage of len() method.

#!/usr/bin/python

str = "this is string example....wow!!!";

print "Length of the string: ", len(str);

Let us compile and run the above program, this will produce the following result:

Length of the string:  32



Advertisements
Advertisements