How do you find the number of letters in a word in python? [duplicate]

You’re looking for the len method, which works on any object with a definable length:

>>>test_string = "Hello"
Hello
>>>len(test_string)
5

For a string, it will treat the string as a list of characters. This means “Hello” has 5, but “Hello ” would have 6, and “Hello World!” would have 12.

docs: https://docs.python.org/3/library/functions.html#len

Leave a Comment