The len() function in Python is the simplest and most efficient way to determine the length of a string, list, tuple, dictionary, or any other iterable. When applied to a string, the len() function returns the total number of characters, including spaces and special symbols.
Syntax of len() function
len(object)
object can be a string, list, tuple, dictionary, or any iterable.
The function returns an integer representing the number of items or characters (in case of string) contained in the object.
String length using len() in Python
str = "netjs"
print(len(str))
str = "Hello World!"
strLen = len(str)
print('length of String- ',strLen)
Output
5 length of String- 12
That's all for this topic String Length in Python - len() Function. If you have any doubt or any suggestions to make please drop a comment. Thanks!
>>>Return to Python Tutorial Page
Related Topics
You may also like-