Python String len() Method


Contents

Description

The len() method in Python String is an in-built function in Python that returns the length of the given string, list, tuple, array, dictionary etc. The input value here is the value given for which you want the length of. The return value in this case is an integer value which is in turn regarded as the length of the given string, list, array or collections.

Syntax

Here is the syntax for len() method:

len( str )

Parameters

  • NA

Return Value

This method is supposed to return the length of the string.

Example

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

#!/usr/bin/python

str = "this is string example....wow!!!";
print "Length of the string: ", len(str)

When we run above program, it produces following result:

Length of the string:  32

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.



Navigation
Tutorial
Tutorial
Tutorial