Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

String length (len)

  • len

The len function returns the length of the string in number of characters.

line = "Hello World"
hw = len(line)
print(hw)  # 11

text = """Hello 
World"""
print(len(text))  # 12