QUESTION Strings Method Len( ) string Python 2

I am currently studying Python 2 free course. I am on a lesson called “String Methods” on the Strings & Console Output Section. The lesson I’m currently on shows four strings and on of those strings is called len( ) which means the length or the number of characters in a string.

My question is does the len( ) string also count the number of spaces in between a word?

Not sure about ver 2, but in ver 3.9, yes - include space:

print(platform.python_version())

str = "1 2 "
print(str.__len__())
print(len(str))
3.9.1
4
4

You can do some simple test.

1 Like