len() string method in Python
The len() string method returns the number of characters in a string.
• It counts letters, digits, spaces, special symbols, and emojis.
• It does not skip spaces or hidden characters like \n (newline) or \t (tab).
Syntax len(string)
• string → Any valid string (sequence of characters).
Example:
Python
text = "Hello" print(len(text)) # Output: 5
Example: String with Spaces.
Python
text = "Hello World" print(len(text)) # Output: 11 # Includes the space between Hello and World