python

Get string length using len() method python

If you want to get the length of a string in Python you can use the len() method of python.

my_str = "The world is beautiful"
print(len(my_str)) #prints 22
Output
22

We are getting the length of a given string my_str here using the python len() method. It will return the number of characters that the string contains.

Was this helpful?