python logo

python string length


Python hosting: Host, run, and code Python in the cloud!

Python’s len() function is used to determine the length of a string. This fundamental function is critical when working with strings in Python.

Syntax

To determine the length of a string in Python, use the len() function. Here’s how:

len(str)

Parameters

When using the len() function, provide the string for which you want to determine the length as the parameter:

String

Example

Let’s look at a practical example to understand how the len() function works:

str = "All work and no play makes Jack a dull boy. Jack?"
strlen = len(str)
print(strlen)

Result

After executing the above code, the output will be:

49

Navigate through the documentation:

BackNext





Leave a Reply: