Python is a fast and powerful open-source, interpretive programming language with extensive standard libraries. When programming in Python, you may need to find the length of a string. For example, you may want to evaluate the amount of characters that a user enters in a text field, and return an error if the text is too long. Using the built-in "len" function, you can quickly calculate the length of a string.
Video of the Day
Access your Python editor.
exampleString = 'This is my example string' len(exampleString);
In this example, Python reads the exampleString and calculates the number of characters in the string using the "len" function. In this example, Python returns '25.'
Note that when calculating the length, Python counts all characters -- including white spaces and special characters.